Thanks!
Now I get another problem :)
On the idbag side I set the collection-id to use a native generator, resulting in the following generated Hibernate create statement:
Code:
create table AccountGroupMember (
memberId NUMERIC(19,0) not null,
groupId NUMERIC(19,0) not null,
id INT IDENTITY NOT NULL,
primary key (id)
)
But when I add add an entity to the relation, Hibernate throws a class cast exception:
Code:
java.lang.ClassCastException
at net.sf.hibernate.type.IntegerType.set(IntegerType.java:31)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)
at net.sf.hibernate.collection.AbstractCollectionPersister.writeIdentifier(AbstractCollectionPersister.java:401)
at net.sf.hibernate.collection.IdentifierBag.writeTo(IdentifierBag.java:291)
at net.sf.hibernate.collection.AbstractCollectionPersister.insertRows(AbstractCollectionPersister.java:622)
at net.sf.hibernate.impl.ScheduledCollectionUpdate.execute(ScheduledCollectionUpdate.java:49)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2303)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2259)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2182
The value passed to IntegerType.set() is an empty String.
It looks like the Hibernate generated SQL insert statement (for the relation table) is incorrect:
Code:
insert into AccountGroupMember (memberId, id, groupId) values (?, ?, ?)
Isn't the database (MS SQL Server in this case) supposed to set the id value itself (as it is an IDENTITY column), and thus the insert statement rather be:
Code:
insert into AccountGroupMember (memberId, groupId) values (?, ?)
Or maybe I've just misunderstood something here...
///Odd