I've got a user/group relationship mapping and i think it might be wrong because the join being created is invalid. anyone have thoughts on this?
tables:
Code:
CREATE TABLE `SECURITY`.`SEC_GROUP` (
`GRP_ID` int(10) NOT NULL AUTO_INCREMENT
PRIMARY KEY (`GRP_ID`),
)
CREATE TABLE `SECURITY`.`SEC_USER` (
`SEC_USER_ID` int(10) NOT NULL AUTO_INCREMENT,
)
CREATE TABLE `SECURITY`.`SEC_USER_GROUP` (
`USER_GRP_ID` int(10) NOT NULL AUTO_INCREMENT,
`GRP_ID` int(10) DEFAULT NULL,
`SEC_USER_ID` int(10) DEFAULT NULL,
PRIMARY KEY (`USER_GRP_ID`),
CONSTRAINT `FK_RFRNC_11` FOREIGN KEY (`GRP_ID`) REFERENCES `SEC_GROUP` (`GRP_ID`),
CONSTRAINT `FK_RFRNC_12` FOREIGN KEY (`SEC_USER_ID`) REFERENCES `SEC_USER` (`SEC_USER_ID`)
)
and they're mapped as:
Code:
<hibernate-mapping package="org"
schema="HD_SECURITY">
<class name="User" table="SEC_USER">
<id name="id" type="int" column="sec_user_id">
<generator class="increment" />
</id>
<one-to-one name="address" class="org.Group"
cascade="all" lazy="false" property-ref="userid" />
</class>
</hibernate-mapping>
<hibernate-mapping package="org"
schema="HD_SECURITY">
<class name="Group" table="SEC_GROUP">
<id name="id" type="int" column="grp_id">
<generator class="increment"/>
</id>
<join table="SEC_USER_GROUP">
<key column="SEC_USER_ID" />
<property name="userid" column="sec_user_id" />
</join>
</class>
</hibernate-mapping>
User is a member of a group. I wanted to just add user id to group from SEC_USER_GROUP and join that mapping to user.
results in this predicate:
Code:
from HD_SECURITY.SEC_USER this_
left outer join HD_SECURITY.SEC_PHONE this_1_ on this_.sec_user_id=this_1_.SEC_USER_ID
left outer join HD_SECURITY.SEC_GROUP group2_ on this_.sec_user_id=group2_.sec_user_id
left outer join HD_SECURITY.SEC_USER_GROUP group2_1_ on group2_.grp_id=group2_1_.SEC_USER_ID where (1=1)
the 2nd outer join is invalid because SEC_USER_ID is on *SEC_USER_GROUP*, not SEC_GROUP as the resulting query suggests.
Is this the wrong way to map it?
Thanks in advance-