Hi guys, I found the following code in the Hibernate reference manual is not working in Hibernate 2.1.6
Cat cat = new DomesticCat();
Cat kitten = new DomesticCat();
....
Set kittens = new HashSet();
kittens.add(kitten);
cat.setKittens(kittens);
session.save(cat);
I traced SQL statement, and found that hibernate create SQL update statement rather than SQL insert statement. But if you delete "cat.setKittens(kittens);" statement, the correct SQL insert statement is created. It looks like hibernate mess up the non-saved id value when the collection is set.
BTW, the above code is working fine in 2.1.5 and 2.1.4 release.
|