I was able to specify that the CAREER_ID could be null
Code:
<many-to-many entity-name="Career">
<column name="CAREER_ID" not-null="false"/>
</many-to-many>
But
Code:
person.getCareerPath().put(newHire,null);
personDAO.save(person);
still doesn't insert anything. And even worse
Code:
getSessionFactory().getCurrentSession().createSQLQuery("INSERT INTO PERSON_CATEGORY (PERSON_ID, CATEGORY_ID, CAREER_ID) values (?,?,null)");
sqlQuery.setInteger(0, id2);
sqlQuery.setInteger(1, capitainCategory.getId());
sqlQuery.executeUpdate();
works perfectly well but when I try to read the person with id2 the null Career doesn't appear.
Code:
Person person3 = personDAO.read(id2);
careerHistory = person3.getCareerHistory();
assertTrue(CollectionUtil.isNotEmpty(careerHistory));
Here my unit test fails because my Map is empty. And it shouldn't because the "manual" insert worked well.