I need to create an idbag in hibernate 3 where the collection-id column defaults to the next value in a sequence. According to the hibernate 3 DTD, the collection-id element looks like this:
<!ELEMENT collection-id (meta*, column*, generator)>
<!ATTLIST collection-id column CDATA #REQUIRED>
<!ATTLIST collection-id type CDATA #REQUIRED>
<!ATTLIST collection-id length CDATA #IMPLIED>
which to my untrained eye says that I can have a column attribute, and a column element. The element allows for a default, but the attribute is required. Hibernate pukes if I have the attribute and the element, so basically the element availability is useless.
The reason I need this working is because I’m going to be inserting into the join table using SQL and would like that auto-generated id.
Is there another way I should be specifying the default value for the id column in an idbag?
One solution is to modify my SQL insert statement to include “nextval( ‘hibernate_sequence’ )” for the id column, but I would prefer to use the hibernate mapping if it’s possible.