I have a map of forms in my Subject (e.g. person) class that uses a another entity as its key like so:
Code:
@ManyToMany (targetEntity=ConsentForm.class)
@MapKey( name="study" )
@JoinTable( name="SUBJECT_CONSENT_FORM",
joinColumns = {@JoinColumn( name="SUBJECT_ID", nullable=false )},
inverseJoinColumns = {@JoinColumn( name="CONSENT_FORM_ID", nullable=false)} )
private Map<Study, ConsentForm> completedConsentForms;
In my ConsentForm class, I have the "study" property like so:
Code:
@ManyToOne
@JoinColumn(name="STUDY_ID", nullable = false)
private Study study;
This study references the Study entity which is declared:
Code:
@Entity
@Table( name="STUDY" )
@SequenceGenerator( name="sequence", sequenceName="id_seq" )
public class Study { ... }
BUT I get the following error, when I try to build the annotation session factory:
Quote:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [spring-core.xml]: Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring-persistence-test.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: Could not determine type for: edu.umich.med.cacr.hb.Study, for columns: [org.hibernate.mapping.Formula( STUDY_ID )]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring-persistence-test.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: Could not determine type for: edu.umich.med.cacr.hb.Study, for columns: [org.hibernate.mapping.Formula( STUDY_ID )]
org.hibernate.MappingException: Could not determine type for: edu.umich.med.cacr.hb.Study, for columns: [org.hibernate.mapping.Formula( STUDY_ID )]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:68)
at org.hibernate.cfg.Configuration.validate(Configuration.java:988)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1169)
. . .
Has anyone seen this problem when using another entity as a MapKey? If I make the Map a Set or List, I no longer get the error.