-->
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.  [ 5 posts ] 
Author Message
 Post subject: Selective Update
PostPosted: Sun Jan 08, 2006 12:47 am 
Regular
Regular

Joined: Sat Jan 07, 2006 8:30 pm
Posts: 68
Hibernate version: 3.0

How do I do a selective update ?

Here's the exact problem. I have a table the is fairly complicated.
I extract the records as list on a web screen page and there I allow user to edit the quantity.

The only columns I have for the whole list are the id(pk) and the quantity.
The rest of the columns are null since that's the way they come from the web page(post/get).

Is there a way to do the update selectively, to pick on choose at the time what to update ?

It has to be a way to do sometimes an update of some fields and sometimes else other field...

Regards,
Q


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 08, 2006 3:45 am 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
Yes, its possible using HQL.
http://www.hibernate.org/hib_docs/v3/re ... tch-direct


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 08, 2006 3:44 pm 
Regular
Regular

Joined: Sat Jan 07, 2006 8:30 pm
Posts: 68
rajasaur wrote:


Thanks! That's useful but ...

I just tried like was mentioned in there - something is definetelly wrong...
Code:
query must begin with SELECT or FROM: update [update Item ...



Here's the code, if I place the query in the xml the error is identical.
Code:
    String hqlUpdate = "update Item set qty = :qty where partipant.id = :paxId  and id = :recordId";
    Query query = getSession().createQuery( hqlUpdate );
    query.setString( "paxId", paxId);
    query.setInteger( "qty", qty );
    query.setInteger( "recordId", id );
    return query.executeUpdate();


Anyone knows why ?
Q


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 08, 2006 11:53 pm 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
Do you by any chance have a "hibernate.query.factory_class" property in your hibernate.cfg.xml (or hibernate.properties) file? If so, please remove it or substitute a value like
hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory

The error you are getting is because you are using the Classic parser for query parsing which does not allow this feature.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 09, 2006 6:05 pm 
Regular
Regular

Joined: Sat Jan 07, 2006 8:30 pm
Posts: 68
True!!!

I was using the clasic parser.


Thanks a lot!!!


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