-->
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: previousState array coming as NULL for Hibernate Interceptor
PostPosted: Sat Jul 12, 2008 10:02 pm 
Newbie

Joined: Thu Jun 12, 2008 9:52 pm
Posts: 11
Hi all,

I have a Class 'A' mapped to Table_A and classes 'B' and 'C' mapped to Table_B and Table_C respectively. The PK in Table_B and Table_C have a foreign key relationship to Table_A.

I fetched an object of 'A' from database using getHibernateTemplate().get(). But when I check for values of 'B' or 'C' inside object 'A', I dont find them. I tried putting getHibernateTemplate().clear() and getHibernateTemplate().flush() after the getHibernateTemplate().get() statement as below.

Code:
getHibernateTemplate().get(A.class, A_ID);
getHibernateTemplate().flush();
getHibernateTemplate().clear();


When I did this, I got it working and I could get objects of B and C populated inside A.

I have written an Interceptor to keep the history of updates. I am getting a NullpointerException inside onflushDirty() because previousState array is coming as null. I doubt this is due to the flush() and clear() that I wrote above. This is making the session forget about the previousState it seems.

Can anyone suggest me a solution to this problem ?

Thanks in advance.

vinodtr


Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

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

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 12, 2008 10:17 pm 
Newbie

Joined: Thu Jun 12, 2008 9:52 pm
Posts: 11
Will it get OK if I call getHibernateTemplate().refresh() instead of clear and flush ???


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.