Suppose this scenario :
class Site has one Sting key : Sitename
class User has two keys (composite key) : Sitename + Username
I wrote User.hbm.xml as follows :
Code:
<class name="foo.User" table="User">
<composite-id>
<key-property name="SiteEnglishName" type="java.lang.String"/>
<key-property name="Username" type="java.lang.String"/>
</composite-id>
</class>
I also implemented equals() and hashCode() in class User.
By this defination , I can query User correctly.
But , when I want to add new User , it just doesn't work.
I am sure I set the two keys correctly.
When I turn set 'show_sql' to true , I found hibernate just 'SELECT' and did nothing.
There is no 'INSERT' statement found.
What's the problem ?
P.S. Hibernate 2.1 beta2