---Continued---
"native" generator for idbag's collection-id is ok only with Oracle (9i).
When used with MySQL, Hibernate will produce an exception when persisting new instances of the association entity:
Code:
Hibernate:
insert
into
DEVIATIONS_PARTS
(DEV_ID, ITEM_ID, AFFECTED_PART_ID, CORRECTIVE_PART_ID)
values
(?, ?, ?, ?)
Code:
Caused by: java.sql.BatchUpdateException: Statement parameter 2 not set.
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
... 25 more
In searching for another generator that would work with both Oracle and MySQL, I have switched from "native" to "increment" for (unit)testing while we are developping the product as I understand that "increment" is not safe when the database is shared by multiple clients.
So the current mater of fact is:
Fact 1) idbag only work (safely) with "sequence" generator.
Fact 2) "sequence" générator is not available under MySQL.
Conclusion) idbag can not be used when the target database is MySQL.
I'm correct ?
Is there an alternative to idbag that I can use to map a ternary association where one of the three foreign key can be null ?
Please help [ I will rate ;-) ]
Pascal Jacob