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.

Fabian Mendez
  • 512
  • 5
  • 15
  • Does this answer your question? [Where/How do You Add Documentation for Kotlin Packages?](https://stackoverflow.com/questions/35212451/where-how-do-you-add-documentation-for-kotlin-packages) – Mahozad May 30 '22 at 10:18

1 Answers1

-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.

Mitchell Skaggs
  • 310
  • 3
  • 11