How do I create a sleeping idbag with the default collection id?

I need to create an idbag in hibernate 3 where the collection id column by default matches the next value in the sequence. According to the hibernate 3 trigger, the collection-id looks like this:

<! ELEMENT collection-id (meta *, column *, generator)>
    & lt! ATTLIST collection-id column CDATA #REQUIRED>
    & lt! ATTLIST collection-id type CDATA #REQUIRED>
    & lt! ATTLIST collection-id length CDATA #IMPLIED>

which, to my untrained eye, says that I can have a column attribute and a column element. Element allows by default, but attribute is required Hibernate pukes if I have an attribute and an element, so basically accessibility of elements is useless.

The reason I need this to work is because I will be inserting into the join table using SQL and would like this auto-generated id.

Is there any other way to specify a default value for the id column in the idbag?

+1


source to share


1 answer


One solution is to change my SQL insert statement to include "nextval (" hibernate_sequence ") for the id column, but I'd rather use hibernate mapping if possible.



0


source







All Articles