-->
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.  [ 9 posts ] 
Author Message
 Post subject: Data Persistence Issue
PostPosted: Fri Feb 10, 2006 6:32 am 
Newbie

Joined: Fri Feb 10, 2006 5:48 am
Posts: 7
Hi All,

We have a critical data persistence issue in our application
while using hibernate.Please can any one suggest a solution...

We have a Static Singelton class which will have all the
hibernate quries and operations. We use this class
across multiple threads in our application.

We open and close session in all the funtions in that class
and to handle session, we use HibernateUtil class API's
like currentSession() and closeSession().

The issue sequence is as follows,
* If we insert a record into a table using hibernate and its
getting reflected in the Database.
* If we query for record/count from that table,
hibernate returns Inconsistent data and it doestn't throw
any Exception
on the console.

Is this a issue with the data persistence ????

We tried the suggestions like
1.tables without any Blob data type.
2.setting the session.flush() during close() session.

but none of the suggestion helped up !!!

Development Environment Details :
Hibernate version:3.0.5
Name and version of the database you are using: MySQL-server-4.1.14
Logging Leve: INFO

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 10, 2006 7:59 am 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:16 am
Posts: 44
Location: Bangalore
Can you just post your hbm files, client class and some more details?
That would be more helpful.
:-)

_________________
Please vote if my Postings helps. :-)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 10, 2006 8:10 am 
Newbie

Joined: Tue Oct 25, 2005 12:28 pm
Posts: 18
Location: London
This sounds like a Transactional problem.

Are you committing the Transaction, or even using Transactions?

_________________
Cheers,
MikeR


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 10, 2006 8:16 am 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:16 am
Posts: 44
Location: Bangalore
In the first place are you sure that the data you are querying is already perisisted in the database.

Because there are possibilities that under multiple cascading, since your hbm files might not have been mapped correctly, only part of the details are persisted and rest aren't?

_________________
Please vote if my Postings helps. :-)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 11, 2006 5:28 am 
Newbie

Joined: Fri Feb 10, 2006 5:48 am
Posts: 7
we have commited all the transactions and we also have a
generic save,update and delete methods that do
the operation within a transaction and commits there itself.

We use more than 4 tables to fetch the result using joins and criteria.
so its hard to upload all the hbm and class files.
[if required, we can do that...]

We are not using any explicit cascading in the table associations.

And we have also checked the database
after inserting/updating, the data is
persistent in the database.But the query that returns the count
just fluctuates between the current count in database
to the pervious count.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 12:52 pm 
Newbie

Joined: Thu Jun 02, 2005 8:23 am
Posts: 3
Location: Belgium - Brussels
This probably isn't a problem with Hibernate but with the storage engine; in fact it's not a bug, it's a feature. The storage engine InnoDB has a feature called 'repeatible read'. Check the InnoDB reference (in the mysql docs) on repeatable read.

It can also lead to ObjectNotFoundException on objects of which you know that the ID is in the database, but the query you use for loading it, has not been commited since it was stored (by another thread).

So it is key that you not only know Hibernate but also the underlying storage engine.

Hope this clears up some confusion,

Steven


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 14, 2006 8:30 am 
Newbie

Joined: Fri Feb 10, 2006 5:48 am
Posts: 7
Thanks Steven !!!!!!

Its working out for me. :-)

I have changed the transaction setting in the MySQL configuration
file to have READ COMMITED and its working well.

For Ref: http://sunsite.mff.cuni.cz/MIRRORS/ftp. ... model.html

Thanks once again !


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 14, 2006 9:05 am 
Newbie

Joined: Fri Feb 10, 2006 5:48 am
Posts: 7
Suggestions appreciated, currently i am
changing the MySQL config file.

Is there any better way to do this programatically
using hibernate/ hibernate settings ????


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 14, 2006 10:15 am 
Newbie

Joined: Thu Jun 02, 2005 8:23 am
Posts: 3
Location: Belgium - Brussels
Padmanaba Prasad wrote:
Suggestions appreciated, currently i am
changing the MySQL config file.

Is there any better way to do this programatically
using hibernate/ hibernate settings ????


Suggestion: you could extend/re-engineer the MySQLInnodDBDialect.java file and override both/either:

public String appendLockHint(LockMode mode, String tableName)
public String transformSelectString(String select)

E.g. you could check wether the 'select' argument passed to the transform method has 'update' in it. When not, you could transform it so it has the suggested InnoDB specific select 'extension' as described in the reference you posted. I didn't do this myself, but if you want to avoid trouble in a multithreaded environment, this could be a route to explore.

See the Dialect.java base class for more info on these methods.

Don't forget to change the configuration dialect to your newly engineered dialect in the hibernate.cfg.xml config file!

Steven

_________________
Independent consultant: Embedded Java - RT Operating systems - Java Virtual Machines - Protocol stacks - Embedded programming in C & Hibernate of course ;-)


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