I am currently evaluating DB-VA and have some problems when generating code & database from UML.

Whenever I use the One-to-One / Many-to-Many / One-to-Many Associations in UML, I can generate the code just fine. But when I try insert data into the database (either from my own class or using the sample), I get the following exception:

17:56:11,515 ERROR AssertionFailure:22 - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: null id in persisttest.Publication entry (don't flush the Session after an exception occurs)
        at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(
        at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(
        at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(
        at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(
        at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(
        at org.hibernate.impl.SessionImpl.flush(
        at org.hibernate.impl.SessionImpl.managedFlush(
        at org.hibernate.transaction.JDBCTransaction.commit(
        at org.orm.PersistentTransaction.commit(
        at ormsamples.CreateTestData.createTestData(
        at ormsamples.CreateTestData.main(

It seems that the primary key is not set at all. For some reason I always get this error when I try to associate two classes. What am I doing wrong? Am I missing something obvious?

I have attached the project file and the mapping for one of the two classes I try to associate.

Thanks for the help,


A new day brought the solution…

In my (a lot more complex) use case, I forgot to fulfill an association with muliplicity 1 on one side and 1…* on the other. This resulted in the error.

When using the test project, it was easy to reproduce this behavior, since all associations mentioned above have a multiplicity of 1 on one side. The auto-generated samples don’t take this into account and therefore you get the same error. I would have thought the samples would consider this. As it is, I am happy that they didn’t because that pointed me directly to the problem in my code.


Thanks Michael
Do you mean that the problem is solved now?

The problem is solved, for me. However, in the situation described above, the auto-generated sample code will not work - something which might be frustrating for new users…

Documentation on this topic would be nice, or, if possible, working sample code.