-->
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.  [ 8 posts ] 
Author Message
 Post subject: Please HELP, concurrency problem
PostPosted: Tue Jun 08, 2004 2:50 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
Hi,

I've developped two applications
--- Step 1 ---

Database is MySQL with InnoDB table type
I'm using Hibernate 2.1.3

I start both applications

--- Step 2 ---
Application #1
Session session = HibernateUtil.currentSession();
Transaction tx = beginTransaction();
Object obj = new Obj();
session.save(obj);
tx.commit();
HibernateUtil.close();

Application #2
Session session = HibernateUtil.currentSession();
List objectList = session.find( "from Object as object WHERE object.code=(?)", code, Hibernate.STRING);
HibernateUtil.close();
First query succeeded, the new object is well selected

Application #1
Session session = HibernateUtil.currentSession();
Transaction tx = beginTransaction();
Object obj = new Obj();
session.save(obj);
tx.commit();
HibernateUtil.close();

Application #2
Session session = HibernateUtil.currentSession();
List objectList = session.find( "from Object as object WHERE object.code=(?)", code, Hibernate.STRING);
HibernateUtil.close();
Second query failed, the new Object is not found

I suppose it is a concurrency error because of when I execute the same sequence in the same application, it works
What can i do to resolve this error ?


Top
 Profile  
 
 Post subject: HELP
PostPosted: Tue Jun 08, 2004 9:39 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
is my request not well explained ?
need more details ?

system with two applications, one application add data by a call to save and the second get data by a call to find function
The second call to find() does not find the new data ... that are stored into database
is it a cache error ?
how does find() work ?
thanks a lot
sorry for my english


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 08, 2004 9:45 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
are you using second level cache?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 08, 2004 9:46 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
I did not know .... how can I get the info


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 08, 2004 9:56 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
reading the doc

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 08, 2004 1:34 pm 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
Parles tu francais ?
I look, but it seem i don't use second cache level
Is there a default second cache configured in hibernate ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 08, 2004 1:46 pm 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
I saw that hibernate use EHCache by default by i did not specify use of cache in my mapping file...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 09, 2004 2:47 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
if you don't configure class cache configuration, there is no reason why a second level should be used.
Are you using one hibernate session per httprequest or do you keep it in httpSession for example.
The best way to manage this hibernate session is to used threadlocal pattern (see open session in view on site).
Yes i speak french and even if my english is bad, let's talk english, this is an english forum.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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