2

I have a custom type for hibernate (TipoSiNo), this is the equivalent of the YesNoType but for spanish (S/N).

When using java I declared this type as the default for boolean fields in a package-info.java file:

@TypeDefs(@TypeDef(name = "si_no", typeClass = TipoSiNo.class, defaultForType = Boolean.class)) package com.xyz; import org.hibernate.annotations.TypeDef; import org.hibernate.annotations.TypeDefs; import com...TipoSiNo; 

This worked fine for java entity classes but when I convert them to kotlin I got an error:

Data conversion error converting "'S'... 

So I supossed I had to convert the package-info file to kotlin:

@file:TypeDefs(TypeDef(name = "si_no", typeClass = TipoSiNo::class, defaultForType = Boolean::class)) package com.xyz import org.hibernate.annotations.TypeDef import org.hibernate.annotations.TypeDefs import com...TipoSiNo 

But even then it does not seem to work.

1

1 Answer 1

-1

There is currently no equivalent of package-info.java for Kotlin. As a workaround, you can simply include a package-info.java in Kotlin and it will be processed.

If you are using Spring Boot, you may run into this additional issue: How to configure package level @TypeDefs with Spring Hibernate :

It seems spring have some issue to scan TypeDef when they are at package-info.java class.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.