-->
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.  [ 1 post ] 
Author Message
 Post subject: many-to-one mapping null after a save
PostPosted: Wed Jun 08, 2005 5:26 pm 
Newbie

Joined: Mon Jul 05, 2004 8:37 am
Posts: 15
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1.4

Mapping documents:

<many-to-one
name="GeneralAcctsData"
column="ACCOUNT_ID"
class="com.dsicdiiti.tnt.oms.general.GeneralData"
insert="false"
update="false"
>
</many-to-one>


Code between sessionFactory.openSession() and session.close():

sess.save(generalData);
.
.
.
(in another class)
.
List entries = sess.createQuery("from GeneralData as detail where "
+ "detail.transactionNumber = :transNumber and detail.flag= :flag")
.setLong("transNumber", data.getTransactionNumber().longValue())
.setString("flag", "Y").list();

Full stack trace of any exception that occurs:

Name and version of the database you are using:

Oracle 9i


I have a problem with a mapping. I have a class that has a mapping to another table with a foreign key. If I save a class using the session it generates a record in the database fine. However, if I try to load the class in the same session the mapping is null. If I close commit the
transaction and then open up another the mapping is valid and I don't get the null.

Is there any way to force the mapping in the same session? Due to the way the system is set up I need to do this within one transaction so I can rollbacl if there is a failure. And the I can not pass the data class around between the various methods. I tried to flush the session before I created my criteria query in the second class, but it did not work. The only way I can get it to work is to execute it within another transaction.

Thanks,
twufire


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

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.