I am trying to create a mapping file so I can use a number of classes with
JPA. I am having an issue figuring out how to map a one-to-many relationship
within the mapping file. I have the relationship working when I use
annotaions, for example:
In the class Actor:
@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
protected List<KeyValuePair> attributes;
I tried to come up with the equivalent in the mapping file and remove the
annotation...my best guess is:
<entity class="project.KeyValuePair"/>
<entity class="project.Actor">
<attributes>
<one-to-many target-entity="project.KeyValuePair"
name="attributes">
<cascade><cascade-all/></cascade>
</one-to-many>
</attributes>
</entity>
however I get the exception:
org.hibernate.MappingException: Could not determine type for: java.util.List,
for columns: [org.hibernate.mapping.Column(availableDataBases)]
javax.persistence.PersistenceException: org.hibernate.MappingException:
Could not determine type for: java.util.List, for columns: [
org.hibernate.mapping.Column(availableDataBases)]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(
Ejb3Configuration.java:698)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory
(HibernatePersistence.java:121)
at javax.persistence.Persistence.createEntityManagerFactory(
Persistence.java:51)
at javax.persistence.Persistence.createEntityManagerFactory(
Persistence.java:33)
I understand that jpa/hibernate is seeing the list and thinking that is
class I was to persist.
I really want to define the mappings in a file since I am generating these
classes from a schema, and there seems to be no way to have JAXB add
annotations to generated classes.
If anyone could please point me in the right direction for?
1) What is wrong with my mapping XML?
2) Can JAXB insert annotations, and how?
3) Where is a good reference for the JPA mapping file?
Thank you all very much!
Lucas