Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

hibernate : ternary association mapped by a map (like book page 347)  RSS feed

pascal gehl
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a unidirectional ternary association like page 347 of the book between
Person (Category in the book), Category (Item in the book) and Career (User in the book).
The difference is that the person_id and the category_id are not nullable but the Career_id can be null in the association table.
When I try to save a Person with a Category in the key of the map but null in the value.
No insert occurs in the PERSON_CATEGORY table.

Is there a way of "telling" hibernate in the mapping to insert a line in PERSON_CATEGORY if the career is null ?

works perfectly well but when I try to read the person with id2 the null Career doesn't appear.

Here my unit test fails because my Map is empty. And it shouldn't because the "manual" insert worked well.



Here are my details.

Hibernate version:3.2.2 ga

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Name and version of the database you are using: hsqldb v 1.8

The generated SQL (show_sql=true):
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!