The following is XML mapping file:
<class name="com.test.webuser.entity.HibernateUser" table="FORUM_USER" dynamic-update="true">
<cache usage="read-write"/>
<id name="ID" type="long">
<generator class="increment"/>
</id>
<property name="username"/>
<property name="password"/>
<property name="fullname"/>
<property name="nickname"/>
<property name="nameVisible"/>
<property name="email"/>
<property name="emailVisible"/>
<property name="lastLogin"/>
<property name="creationDate"/>
<property name="modifiedDate"/>
<set name="groups" table="FORUM_USER_GROUP" lazy="false">
<cache usage="read-write"/>
<key column="userID"/>
<many-to-many class="com.gpower.services.webuser.entity.HibernateGroup" column="groupID"/>
</set>
</class>
<class name="com.test.webuser.entity.HibernateGroup" table="FORUM_GROUP">
<cache usage="read-write"/>
<id name="ID" type="long">
<generator class="increment"/>
</id>
<property name="name"/>
<property name="description"/>
<set name="users" table="FORUM_USER_GROUP" lazy="false">
<cache usage="read-write"/>
<key column="groupID"/>
<many-to-many class="com.gpower.services.webuser.entity.HibernateUser" column="userID"/>
</set>
</class>
The dialet is OracleDialet
After run, the SQL is:
Hibernate: select groups0_.userID as userID__, groups0_.groupID as groupID__, hibernateg1_.ID as ID0_, hibernateg1_.name as name0_, hibernateg1_.description as descript3_0_ from FORUM_USER_GROUP groups0_ inner join FORUM_GROUP hibernateg1_
on groups0_.groupID=hibernateg1_.ID where groups0_.userID=?
But Oracle 8 doesn't support inner join.
The Hibernate version 2.1.6.
When HibernateUser hasn't dynamic-update="true" or database is Microsoft SQLServer, it's ok.
|