-->
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.  [ 1 post ] 
Author Message
 Post subject: problem with HQL update
PostPosted: Wed Mar 02, 2011 1:32 pm 
Newbie

Joined: Wed Mar 02, 2011 11:28 am
Posts: 1
Hello
I see in the documentation that exits the method query.executeUpdate , but I don't find in Hibernate 2.2
in the example

As an example, to execute an HQL UPDATE, use the Query.executeUpdate() method The method is named for those familiar with JDBC's PreparedStatement.executeUpdate():

Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();

String hqlUpdate = "update Customer c set c.name = :newName where c.name = :oldName";
// or String hqlUpdate = "update Customer set name = :newName where name = :oldName";
int updatedEntities = s.createQuery( hqlUpdate )
.setString( "newName", newName )
.setString( "oldName", oldName )
.executeUpdate();
tx.commit();
session.close();

y try to do in c# hibernate 2.2

public void SetMainPhoto()
{
ISession session = this._sessionManager.OpenSession();

String hql = "update cm_photorotation set mainfoto = :mainfoto where sectionid = :sectionid";
IQuery query = session.CreateQuery(hql);
query.SetBoolean("mainfoto", false);
query.SetInt32("sectionid",base.Section.Id);

}
don´t exist query.executeUpdate() ,

¿ exist another method similar ?
many thanks and sorry for my english


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.