Je me demande s'il est possible d'implémenter le modèle de domaine suivant.Grails: mappage de classe de domaine (collection de types d'utilisateurs hibernate)
Ayons une classe de domaine qui contient un ensemble d'intervalles (temps joda). Je peux utiliser le type d'utilisateur hibernate org.joda.time.contrib.hibernate.PersistentInterval pour le mappage de Interval à la table de base de données (de la même manière que dans http://www.grails.org/JodaTime+Plugin). Cependant, je ne peux pas comprendre comment implémenter le mapping si j'ai un ensemble d'intervalles, pas seulement un intervalle.
Exemple:
class Activity { ... Set intervals = [] ... static hasMany = [ intervals: org.joda.time.Interval ] // This is incorrect implementation, I have set of intervals // and this would be correct if I had only one interval // How to implement mapping in this case? static mapping = { intervals type: PersistentInterval, { column name: "start" column name: "end" } }
}
mise en œuvre ci-dessus échoue avec l'erreur suivante:
2010-10-23 18:30:25,483 [main] ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Foreign key (FK4FDC5B1E5107CA0:activity_intervals [start,end])) must have same number of columns as the referenced primary key (activity [id]) org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Foreign key (FK4FDC5B1E5107CA0:activity_intervals [start,end])) must have same number of columns as the referenced primary key (activity [id]) at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:212)
Je pensais que le travail autour de cette question est d'extraire l'intervalle de classe de domaine distinct extension d'intervalle et spécifier la cartographie dans les il. Cependant, Interval est la classe finale, donc l'extension n'est pas possible.
Merci pour vos conseils.