-->
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.  [ 3 posts ] 
Author Message
 Post subject: Thread question
PostPosted: Mon May 09, 2005 7:43 pm 
Newbie

Joined: Wed Apr 27, 2005 9:53 am
Posts: 10
Quick question

Here is an example of code that is not working as i am expecting. All code in a single Thread.

session = sessionFactory.openSession();
session.setCacheMode(CacheMode.IGNORE);

menu = (Menu)session.createQuery("from Menu where menuId = "+menuId).uniqueResult();

menu contains object content,

content = menu.getContent();

tx = session.beginTransaction();
session.delete(content);
tx.commit();

in same thread few lines of code later

menu = (Menu)session.createQuery("from Menu where menuId = "+menuId).uniqueResult();
content = menu.getContent();

session.close();

content is not null, how i can make the code make the content be null on the 2th attemp ?

Antoine


Hibernate version: 3.0

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:


Top
 Profile  
 
 Post subject: Re: Thread question
PostPosted: Mon May 09, 2005 11:43 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
antoinepraetor wrote:
Quick question

Here is an example of code that is not working as i am expecting. All code in a single Thread.

session = sessionFactory.openSession();
session.setCacheMode(CacheMode.IGNORE);

menu = (Menu)session.createQuery("from Menu where menuId = "+menuId).uniqueResult();

menu contains object content,

content = menu.getContent();

tx = session.beginTransaction();
session.delete(content);
tx.commit();

in same thread few lines of code later

menu = (Menu)session.createQuery("from Menu where menuId = "+menuId).uniqueResult();
content = menu.getContent();

session.close();

content is not null, how i can make the code make the content be null on the 2th attemp ?

Antoine


The session.delete(content) statement deletes the "content" from the database. It doesn't change the value of content. As long as you maintain a reference to it, it's still a valid java object.

See section 10.8 of the reference doc.[/code]


Top
 Profile  
 
 Post subject: Re: Thread question
PostPosted: Mon May 09, 2005 11:49 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
pksiv wrote:

The session.delete(content) statement deletes the "content" from the database. It doesn't change the value of content. As long as you maintain a reference to it, it's still a valid java object.

See section 10.8 of the reference doc.[/code]


I just noticed that this is section 11.8 in the 3.0.3 docs.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.