Hi,
I fully read the document on
http://www.hibernate.org/hib_docs/reference/html/. However, I still get problems in one-to-many mapping. I have two tables, OneCXN_User and USER_SMSISDN in Oracle 9i The relationship of OneCXN_User to USER_SMSISDN is one to many. I have created similar Objects for those tables in which OneCXN_User has a Set to collect all associate USER_SMSISDN records. However, when I query the OneCXN_User through Hibernate, the size of Set that constain USER_SMSISDN in OneCXN Object is 0 but I been confirmed that I have put testing data that has relationship already.
My xml is as following.
<class name="OneCXNUser" table="ONECXN_USER">
<id name="imsi" type="string" unsaved-value="null" >
<column name="IMSI" sql-type="varchar(20)" not-null="true"/>
<generator class="uuid.hex"/>
</id>
<property name="homewkID" type="int">
<column name="HOME_NETWORKID" sql-type="number(2)"
not-null="true"/>
</property>
<property name="pmsisdn">
<column name="PMSISDN" sql-type="varchar(20)"
not-null="false"/>
</property>
<set name="smsisdn" table="USER_SMSISDN" lazy="true"
cascade="all">
<key column="PMSISDN"/>
<one-to-many class="UserSMsisdn" />
</set>
</class>
<class name="UserSMsisdn" table="USER_SMSISDN">
<composite-id>
<key-property name="secwkID" type="int">
<column name="SEC_NETWORKID" sql-type="number(16)"
not-null="true"/>
</key-property>
<key-property name="smsisdn" type="string">
<column name="sMSISDN" sql-type="varchar(16)"
not-null="true"/>
</key-property>
</composite-id>
<many-to-one name="onecxnUser" column="PMSISDN"
class="OneCXNUser"
not-null="true" cascade="all"/>
</class>
My Java Bean class are as following
public class OneCXNUser {
private String imsi=null;
private int homewkID=0;
private HomeNetwork homewk=null;
private String pmsisdn=null;
private Set smsisdn=null;
getter/setter method...
}
public class UserSMsisdn {
private int secwkID=0;
private String pmsisdn=null;
private String smsisdn=null;
private OneCXNUser onecxnUser=null;
getter/setter method...
}
My Query are following
select oneCXNUser from OneCXNUser as oneCXNUser left outer join oneCXNUser.smsisdn as userSMsisdn
Output of Hiberate screen
15:28:34,247 INFO [STDOUT] Hibernate: select onecxnus0_.IMSI as IMSI, onecxnus0
_.HOME_NETWORKID as HOME_NET2_, onecxnus0_.PMSISDN as PMSISDN, onecxnus0_.HLR_GT_ADDR as HLR_GT_A4_ from ONECXN_USER onecxnus0_, USER_SMSISDN smsisdn1_ where on
ecxnus0_.IMSI=smsisdn1_.PMSISDN(+)
15:28:34,277 INFO [STDOUT] Hibernate: select onecxnus0_.IMSI as x0_0_ from ONECXN_USER onecxnus0_, USER_SMSISDN smsisdn1_ where onecxnus0_.IMSI=smsisdn1_.PMSIS
DN(+)
15:28:34,287 INFO [STDOUT] Hibernate: select user_sms0_.SEC_NETWORKID as SEC_NETW1___, user_sms0_.sMSISDN as sMSISDN__, user_sms0_.SEC_NETWORKID as SEC_NETWORK
ID, user_sms0_.sMSISDN as sMSISDN, user_sms0_.PMSISDN as PMSISDN from USER_SMSISDN user_sms0_ where user_sms0_.PMSISDN=?
Please help to point what's wrong on my setting that why I cannot return any USER_SMSISDN in the Set of OneCXNUser upon the query.
Thanks in advance.