I just coded my first Hibernate examples.
The database connection works and I understand how I can map a String from a POJO to a database field:
private String firstName;
And in the mapping file:
<property name="firstName" type="java.lang.String">
<column name="FIRSTNAME" />
</property>
But how can I map an ArrayList to the database? A simpl example from the mapping xml file would be appreciated.
Cheers
UPDATE
I switched to List instead of ArrayList found an example. Now I map as follows:
<list name="test" inverse="false" table="CONTACT" lazy="true">
<key>
<column name="ID" />
</key>
<list-index></list-index>
<element type="java.lang.String">
<column name="TEST" />
</element>
</list>
Unfortunately, I get an exception that I do not understand:
Exception in thread "main" org.hibernate.MappingException: Foreign key (FK6382B0003257FF7F:CONTACT [ID])) must have same number of columns as the referenced primary key (CONTACT [ID,idx])
Any ideas?
Cheers