I am using Hibernate 3.2 with annotations and JPA. I am converting some old hibernate mapping files to use annotations.
Here is how the mapping looks like:
<list name="scenarios" table="saved_view_scenario">
<key column="saved_view_id" />
<index column="element_order" />
<composite-element class="amazon.otb.common.view.SavedViewScenario">
<parent name="savedView" />
<many-to-one name="scenario" column="scenario_id" class="amazon.otb.common.Scenario" />
<property name="modifications" not-null="true"/>
</composite-element>
</list>
<list name="dataElements" table="saved_view_data_element">
<key column="saved_view_id" />
<index column="element_order" />
<many-to-many column="data_element_id" class="amazon.otb.common.DataElement" />
</list>
I converted first relationship as:
@Embedded
@JoinTable(
name="saved_view_scenario",
joinColumns={@JoinColumn(name="saved_view_id")}
)
@OrderBy("element_order")
public List<SavedViewScenario> getScenarios() {
return this.scenarios;
}
and second as
/**
* @return dataelements
*/
@JoinTable(
name="saved_view_data_element", joinColumns={@JoinColumn(name="saved_view_id")}
)
@OrderBy("element_order")
public List<DataElement> getDataElements() {
return this.dataElements;
}
But I am getting
[java] Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, for columns: [org.hibernate.mapping.Column(dataElements)]
[java] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
[java] at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
[java] at org.hibernate.mapping.Property.isValid(Property.java:185)
[java] at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:440)
[java] at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
[java] at org.hibernate.cfg.Configuration.validate(Configuration.java:1102)
[java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
[java] at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
[java] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
[java] ... 34 more
I would appreciate if someone can suggest corresponding syntax with JPA compliant annotations.
|