我可以在hibernate实体中使用ClosedRange <t>吗?

时间:2017-11-06 14:11:50

标签: hibernate kotlin

使用ClosedRange<T>

时,Hibernate会抛出异常

我知道四处走动是使用@Entity@Embeddable创建自己的Range类, 但没有其他解决方案?

例外:

org.hibernate.MappingException: Could not determine type for: kotlin.ranges.IntRange, at table: Foo, for columns: [org.hibernate.mapping.Column(myRange)]

实体:

@Entity
class Foo (
    @Id @GeneratedValue var id: Long? = null,
    var myRange: IntRange = 0..0
)

1 个答案:

答案 0 :(得分:0)

@Entity
data Foo (
    @Id @GeneratedValue var id: Int? = null,
    var target: IntRange = target in 0..100  
)