-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Session.get() returning null
PostPosted: Mon Jun 11, 2007 11:40 am 
Newbie

Joined: Wed May 30, 2007 4:14 pm
Posts: 15
I'm using Spring and Struts, and now trying to pull Hibernate into the mix. I've got a struts form. The form allows 1 user with 1 address. My data model supports 1 user with many addresses. I simply want to take the struts form object and persist it over the two tables. If I pull only from the user table, I get my record. When I add the <join> to my hbm-xml file, I get nothing returned from the get(). I've taken the SQL from the logs and run it in sql developer and it returns my record. I've also stepped through to make sure my id value (which is currently hardcoded) is available, and it is there.

Hibernate 3.2.3
Oracle 9i

Mapping documents:
<class name="com.futuresoldiers.struts.form.TempRegistrationForm" table="USERNAME">
<id name="tempUserId" type="long" column="USERNAME_ID">
<generator class="com.futuresoldiers.dao.hibernate.TriggerAssignedIdentityGenerator"/>
</id>
<property name="emailAddress" type="string" column="EMAIL_TX"/>
<property name="firstName" type="string" column="FIRST_NAME_TX"/>
<property name="lastName" type="string" column="LAST_NAME_TX"/>
<property name="status" type="string" column="STATUS_CD"/>
<property name="dateOfBirth" type="date" column="DOB_DT"/>
<property name="createdBy" type="string" column="create_by"/>
<property name="createdDate" type="date" column="create_dt"/>
<property name="modifiedDate" type="date" column="mod_dt"/>
<property name="modifiedBy" type="string" column="mod_by"/>
<property name="lastAccessed" type="date" column="last_access_dt"/>
<join table="ADDRESS">
<key>
<column name="USERNAME_ID" not-null="true"/>
</key>
<property name="address1" type="string" column="ADDRESS1_TX"/>
<property name="address2" type="string" column="ADDRESS2_TX"/>
<property name="city" type="string" column="CITY_TX"/>
<property name="state" type="string" column="STATE_CD"/>
<property name="zipCode" type="string" column="ZIP_CD"/>
</join>
</class>


Code between sessionFactory.openSession() and session.close():
Session session = getSession();
TempRegistrationForm record = new TempRegistrationForm();
Long a = new Long(21);
try {
record = (TempRegistrationForm) session.get(TempRegistrationForm.class, a);

Record is returning null, but when I run the sql below, replacing with my value, I get the record I am looking for back.

The generated SQL (show_sql=true):
select
tempregist0_.USERNAME_ID as USERNAME1_5_0_,
tempregist0_.EMAIL_TX as EMAIL2_5_0_,
tempregist0_.FIRST_NAME_TX as FIRST3_5_0_,
tempregist0_.LAST_NAME_TX as LAST4_5_0_,
tempregist0_.STATUS_CD as STATUS5_5_0_,
tempregist0_.DOB_DT as DOB6_5_0_,
tempregist0_.create_by as create7_5_0_,
tempregist0_.create_dt as create8_5_0_,
tempregist0_.mod_dt as mod9_5_0_,
tempregist0_.mod_by as mod10_5_0_,
tempregist0_.last_access_dt as last11_5_0_,
tempregist0_1_.ADDRESS1_TX as ADDRESS2_6_0_,
tempregist0_1_.ADDRESS2_TX as ADDRESS3_6_0_,
tempregist0_1_.CITY_TX as CITY4_6_0_,
tempregist0_1_.STATE_CD as STATE5_6_0_,
tempregist0_1_.ZIP_CD as ZIP6_6_0_
from
DBO_FSOL.USERNAME tempregist0_,
DBO_FSOL.ADDRESS tempregist0_1_
where tempregist0_.USERNAME_ID=tempregist0_1_.USERNAME_ID
and tempregist0_.USERNAME_ID=21

Any help would be really appreciated.


Top
 Profile  
 
 Post subject: POST UPDATE
PostPosted: Tue Jun 12, 2007 6:54 pm 
Newbie

Joined: Wed May 30, 2007 4:14 pm
Posts: 15
no replies - :(

We'll scrap using hibernate because, I'm not sure where everyone else programs, but we have a very tight deadline.

NO need to reply


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.