我有一个类似于以下使用 JodaTime 的 Interval 类的类。Joda Time Grails 插件不支持开箱即用的 Interval 字段,因此我尝试根据Rob 的建议如何坚持 DateTimeTZ自己映射它。
import org.jadira.usertype.dateandtime.joda.PersistentInterval
import org.joda.time.Interval
class Offer {
Interval time
static mapping = {
time type: PersistentInterval, {
column name: "start_date_time"
column name: "end_date_time"
}
}
}
我的问题是我收到以下异常。
Caused by: java.lang.RuntimeException: Cannot treat multi-column property as a single-column property
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:991)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1375)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 111 more
有人知道如何正确映射间隔吗?