-->
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: size function produces invalid sql for oracle 10g
PostPosted: Tue Mar 15, 2011 10:49 am 
Newbie

Joined: Thu Mar 03, 2011 3:24 pm
Posts: 9
When hibernate parses out this hql:

Code:
UPDATE VERSIONED Person SET groupsCount = followingGroup.size WHERE id = :id

it generates this sql:

Code:
UPDATE Person
  SET version  =version+1,
  groupsCount=
  (SELECT COUNT(followingg1_.followerId)
     FROM GroupFollower followingg1_
    WHERE Person.id=followingg1_.followerId
  )-1
  WHERE id IN
  (SELECT groupfollo2_.followerId
     FROM GroupFollower groupfollo2_
    WHERE groupfollo2_.followingId=?
  )


That query fails at the "-1" after the subquery for the count of the followingids. If i take out the "-1" it runs just fine, or if i move the "-1" to "SELECT COUNT(followingg1_.followerId) - 1" it also works.

If this is indeed a bug, is there some way to override this behavior with some custom methods in a custom oracle dialect? Or other ways to get around this?


Top
 Profile  
 
 Post subject: Re: size function produces invalid sql for oracle 10g
PostPosted: Thu Mar 17, 2011 10:49 am 
Newbie

Joined: Thu Mar 03, 2011 3:24 pm
Posts: 9
is there perhaps some way to at least override this sql generation in hibernate, so I could just do it once, rather than in every place this hql is present in the app?


Top
 Profile  
 
 Post subject: Re: size function produces invalid sql for oracle 10g
PostPosted: Thu Mar 17, 2011 12:14 pm 
Newbie

Joined: Thu Mar 03, 2011 3:24 pm
Posts: 9
sorry, realized that the offending code was actually being generated by

Code:
UPDATE VERSIONED Person SET groupsCount = followingGroup.size - 1 WHERE id IN etc..


there is a bug in oracle 10g about this - http://forums.oracle.com/forums/thread. ... ID=2192872


so changing that to

Code:
UPDATE VERSIONED Person SET groupsCount = -1 + followingGroup.size WHERE id IN etc..



works-


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.