-->
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: Implementing Uncommitted reads.
PostPosted: Wed Feb 15, 2006 10:39 am 
Newbie

Joined: Tue Feb 14, 2006 6:33 pm
Posts: 3
Location: Canada
Hi,

I want to implement uncommitted reads with hibernate, I have a mapping for a bean (Parent), that bean has many-to-one relationship with another bean (Children).

I want to implement the uncommitted reads strategy while selecting (Parent). I did use an HQL query appending "with ur" to the query and it worked fine, but the "with ur" is not working for (Children).

I want to find a way to implement the uncommitted reads for the bean and all its children. In other words, being able to perform 'dirty reads' on the children (when the are updated in an another transaction).

I don't know if hibernate supports that.

The UR strategy needs to be at the transaction level.

thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 11:03 am 
Regular
Regular

Joined: Sun May 08, 2005 2:48 am
Posts: 118
Location: United Kingdom
What scope ? The session ? The transaction ? Just a batch of multiple querys ? Just one query ?

I would guess there is a way to make the whole session run with a different isolation level:

See hibernate.connection.isolation in http://www.hibernate.org/hib_docs/refer ... ml_single/


I think the "with ur" was just HQL passing that directly to your underlying DB ?


But you are asking is for a query to use READ-UNCOMMITED and all the resulting lazy loading to also use the same ? This request is somewhat difficult, since once an object is retrieved its an object and doesn't carry any attributes relating to the original query that got it.

Maybe you can setup a transaction in hibernate to use a different isolation level ?


So I think your only way out is to make a session use a different isolation level, and if necessary use 2 session instances in your task.

HTH


Top
 Profile  
 
 Post subject: Uncommitted reads
PostPosted: Wed Feb 15, 2006 12:10 pm 
Newbie

Joined: Tue Feb 14, 2006 6:33 pm
Posts: 3
Location: Canada
Thanks for the quick reply.

I want to implement the UR at the transaction level (just one query), and I cannot use the hibernate.connection.isolation since I'm using the application server datasource that will override the initial hibernate setting.

I already did try to change thta isolation level in the session (session.connection().setTransactionIsolationLevel) but it didn't work.

Using the "with UR" in the HQL worked just fine, but somehow, it's not applying that dirty read to the evenual children. That's true that the HQL will pass the "with ur" directly to the DB, the select on the parent bean will be performed "with UR", but the children will not be retrieved using the "with ur".

If u have an order, having many items, the "with ur" will only work for order not for items.

I'm still trying to find out a way to achieve that, but so far I'm totally lost :-)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 17, 2006 1:55 am 
Regular
Regular

Joined: Sun May 08, 2005 2:48 am
Posts: 118
Location: United Kingdom
The only remaining thing to add is that are you really sure you need it ? I can't think of anything I do that wants to work with UNCOMMITTED data.


Top
 Profile  
 
 Post subject: Uncommitted reads
PostPosted: Fri Feb 17, 2006 10:30 am 
Newbie

Joined: Tue Feb 14, 2006 6:33 pm
Posts: 3
Location: Canada
I know that UR are dangerous and should be avoided but actually I'm working on a project and we are having a lot of 913 errors (DB2). This is caused by resource contention, so somebody decided to implement these URs to avoid having timeouts. Thus, the read-only queries will not be blocked by other updates.
The problem we're having is that our transactions run for a long time, we have mass updates (on hundreds of thousands of records) that take around 1 minutes !!! and as hibernate framework is a bit heavy, doing a lot of stuff in the background, that increases the transaction duration.
So the decision of implementing URs was taken and I had to propose a solution for that.

I found that it's doiable using HQL queries and appending "with UR", but the problem is that if there r some <one-to-many> associations, those children will not be read using the "with UR" clause (the "with ur" will not be progagated to the children), and there's nothing in the mapping syntax to allow that.


Top
 Profile  
 
 Post subject: Uncommitted reads
PostPosted: Wed Sep 20, 2006 11:42 am 
Newbie

Joined: Wed Sep 20, 2006 11:29 am
Posts: 1
Location: GTA
How exaclty did you manage to use "with UR" clause in your HQL expression?

I am using Hibernate 3 and HQL parser seems to reject "with UR" at the end of query.

E.g.:
When parsing "from AlertMessage am with UR"
I get an exception:
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: with near line 1, column 56 [from ca.olgc.rtcc.tgms.business.domain.AlertMessage am with UR]

Using lowercase "ur" does not make difference:
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: with near line 1, column 56 [from ca.olgc.rtcc.tgms.business.domain.AlertMessage am with ur]

Thank you in advance!

Best regards.


Top
 Profile  
 
 Post subject: Re: Implementing Uncommitted reads.
PostPosted: Tue Feb 02, 2010 2:32 pm 
Newbie

Joined: Thu Jan 21, 2010 3:20 pm
Posts: 17
Even I tried using "with ur" it throws the above mentioned exception

org.hibernate.hql.ast.QuerySyntaxException: unexpected token: with near line 11, column 49


Top
 Profile  
 
 Post subject: Re: Implementing Uncommitted reads.
PostPosted: Tue Mar 16, 2010 4:18 pm 
Newbie

Joined: Thu Jan 21, 2010 3:20 pm
Posts: 17
Hi Everybody,

Any pointers on Uncommited read. I am using Spring-Hibernate annotation based Uncommited reads. Is it not same "with UR" ??

Regards,
lrow


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.