-->
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.  [ 7 posts ] 
Author Message
 Post subject: HQL update exception
PostPosted: Fri Oct 14, 2005 5:54 am 
Newbie

Joined: Fri Apr 15, 2005 8:08 am
Posts: 6
I tried to update a very simple hql:

UPDATE TblProduct p SET p.TblCubeLayout=:nulllayout where p.TblCubeLayout=:layout

However, I got exception :

*** ERROR: line 1:19: expecting "set", found 'p'
org.hibernate.hql.ast.QuerySyntaxError: expecting "set", found 'p' near line 1, column 19 [UPDATE TblProduct p SET p.TblCubeLayout=:nulllayout where p.TblCubeLayout=:layout]

If I remove the alias name p as the following, it works.

UPDATE TblProduct SET TblCubeLayout=:nulllayout where TblCubeLayout=:layout

Anybody has some idea?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 5:57 am 
Beginner
Beginner

Joined: Thu Aug 11, 2005 5:19 am
Posts: 29
Hi,

you have a false syntax for batch update.

Try: "UPDATE TblProduct SET TblCubeLayout=:nulllayout where TblCubeLayout=:layout "

(don't sure if SET'll work)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 6:09 am 
Newbie

Joined: Fri Apr 15, 2005 8:08 am
Posts: 6
Danny L. wrote:
Hi,

you have a false syntax for batch update.

Try: "UPDATE TblProduct SET TblCubeLayout=:nulllayout where TblCubeLayout=:layout "

(don't sure if SET'll work)


This is what I tried. Yes, if remove the alias name, it works. Does this mean I cannot use alias name in update HQL. If it is, I think it is unreasonable because we can use it in sql. Anyway, thanks. Does anybody have other explaination or something is wrong in this HQL?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 6:27 am 
Beginner
Beginner

Joined: Thu Aug 11, 2005 5:19 am
Posts: 29
There's no other explanation :)
You can't use aliases.
BTW UPDATE/DELETE in HQL is a quite new feature anyway ;)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 6:33 am 
Beginner
Beginner

Joined: Thu Aug 11, 2005 5:19 am
Posts: 29
by the way

it was A BUG :)

And is fixed in the new Hibernate version 3.1 RC
I just tried it and it works!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 12:08 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Technically it wasn't a bug. The older documentation *clearly* stated that using aliases in UPDATE/DELETE statements was not yet supported :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 5:01 pm 
Beginner
Beginner

Joined: Thu Aug 11, 2005 5:19 am
Posts: 29
OK, maybe it was a feature and not a bug ;)

But in 3.1 RC1 implementation of bulk DEL/UPD is announced as a bug fix ;)


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