-->
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: [Query].executeUpdate() does not exist in hibernate 3.0?
PostPosted: Mon Mar 14, 2005 11:42 am 
Beginner
Beginner

Joined: Tue Feb 01, 2005 8:38 am
Posts: 38
Hibernate version: 3.0

There is no executeUpdate method in the Query class in hibernate 3.0. I have seen examples in the unit test code such as...

session.createQuery( "delete Animal" ).executeUpdate();

...how are you supposed to execute a line like that in 3.0.

Cheers,

John :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 14, 2005 11:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Of course it does, even the test cases use it - you are using some old Hibernate version or something.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 14, 2005 12:04 pm 
Beginner
Beginner

Joined: Tue Feb 01, 2005 8:38 am
Posts: 38
michael wrote:
Of course it does, even the test cases use it - you are using some old Hibernate version or something.


Hi Michael,

I'm using hibernate 3.0, i.e. hibernate3.jar extracted from hibernate-3.0beta2.zip which I downloaded about a month ago. Please correct me where I'm wrong here...

Class org.hibernate.Query should have a method executeUpdate(), yeah? Well, my Query class definitey does not have this method. The method is not even listed in the API that's distributed with Hibernate 3.0. Below is the list of methods in the Query class that I am using.

Code:
String[] getNamedParameters()
          Return the names of all named parameters of the query.

String getQueryString()
          Get the query string.

Type[] getReturnTypes()
          Return the Hibernate types of the query result set.

Iterator iterate()
          Return the query results as an Iterator.

List list()
          Return the query results as a List.

ScrollableResults scroll()
          Return the query results as ScrollableResults.

ScrollableResults scroll(ScrollMode scrollMode)
          Return the query results as ScrollableResults.

Query setBigDecimal(int position, BigDecimal number)
           
Query setBigDecimal(String name, BigDecimal number)
           
Query setBinary(int position, byte[] val)
           
Query setBinary(String name, byte[] val)
           
Query setBoolean(int position, boolean val)
           
Query setBoolean(String name, boolean val)
           
Query setByte(int position, byte val)
           
Query setByte(String name, byte val)
           
Query setCacheable(boolean cacheable)
          Enable caching of this query result set.

Query setCacheRegion(String cacheRegion)
          Set the name of the cache region.

Query setCalendar(int position, Calendar calendar)
           
Query setCalendar(String name, Calendar calendar)
           
Query setCalendarDate(int position, Calendar calendar)
           
Query setCalendarDate(String name, Calendar calendar)
           
Query setCharacter(int position, char val)
           
Query setCharacter(String name, char val)
           
Query setComment(String comment)
          Add a comment to the generated SQL.

Query setDate(int position, Date date)
           
Query setDate(String name, Date date)
           
Query setDouble(int position, double val)
           
Query setDouble(String name, double val)
           
Query setEntity(int position, Object val)
          Bind an instance of a mapped persistent class to a JDBC-style query parameter.

Query setEntity(String name, Object val)
          Bind an instance of a mapped persistent class to a named query parameter.

Query setFetchSize(int fetchSize)
          Set a fetch size for the underlying JDBC query.

Query setFirstResult(int firstResult)
          Set the first row to retrieve.

Query setFloat(int position, float val)
           
Query setFloat(String name, float val)
           
Query setFlushMode(FlushMode flushMode)
          Override the current session flush mode, just for this query.

Query setForceCacheRefresh(boolean forceCacheRefresh)
          Should the query force a refresh of the specified query cache region? This is particularly useful in cases where underlying data may have been updated via a seperate process (i.e., not modified through Hibernate) and allows the application to selectively refresh the query cache regions based on its knowledge of those events.

Query setInteger(int position, int val)
           
Query setInteger(String name, int val)
           
Query setLocale(int position, Locale locale)
           
Query setLocale(String name, Locale locale)
           
Query setLockMode(String alias, LockMode lockMode)
          Set the lockmode for the objects idententified by the given alias that appears in the FROM clause.

Query setLong(int position, long val)
           
Query setLong(String name, long val)
           
Query setMaxResults(int maxResults)
          Set the maximum number of rows to retrieve.

Query setParameter(int position, Object val)
          Bind a value to a JDBC-style query parameter, guessing the Hibernate type from the class of the given object.

Query setParameter(int position, Object val, Type type)
          Bind a value to a JDBC-style query parameter.

Query setParameter(String name, Object val)
          Bind a value to a named query parameter, guessing the Hibernate type from the class of the given object.

Query setParameter(String name, Object val, Type type)
          Bind a value to a named query parameter.

Query setParameterList(String name, Collection vals)
          Bind multiple values to a named query parameter, guessing the Hibernate type from the class of the first object in the collection.

Query setParameterList(String name, Collection vals, Type type)
          Bind multiple values to a named query parameter.

Query setParameterList(String name, Object[] vals)
          Bind multiple values to a named query parameter, guessing the Hibernate type from the class of the first object in the array.

Query setParameterList(String name, Object[] vals, Type type)
          Bind multiple values to a named query parameter.

Query setParameters(Object[] values, Type[] types)
          Bind values and types to positional parameters.

Query setProperties(Object bean)
          Bind the property values of the given bean to named parameters of the query, matching property names with parameter names and mapping property types to Hibernate types using hueristics.

Query setReadOnly(boolean readOnly)
           
Query setSerializable(int position, Serializable val)
           
Query setSerializable(String name, Serializable val)
           
Query setShort(int position, short val)
           
Query setShort(String name, short val)
           
Query setString(int position, String val)
           
Query setString(String name, String val)
           
Query setText(int position, String val)
           
Query setText(String name, String val)
           
Query setTime(int position, Date date)
           
Query setTime(String name, Date date)
           
Query setTimeout(int timeout)
          Set a timeout for the underlying JDBC query.

Query setTimestamp(int position, Date date)
           
Query setTimestamp(String name, Date date)
           
Object uniqueResult()
          Convenience method to return a single instance that matches the query, or null if the query returns no results.




The only methods that can be used to execute a query are list(), scroll(), and iterate() but these all expect that your query will return a resultset and therefore throw an exception if the query doesn't start with Select or From.


Is there something I'm missing here?

Cheers,

John :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 14, 2005 12:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
The current version is 3.0-rc1


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 14, 2005 9:39 pm 
Newbie

Joined: Wed Feb 23, 2005 11:29 am
Posts: 9
I am using 3.0-rc1 and it does not work for me.

session.createQuery("delete from Foo").executeUpate();

executeUpate is typo error for executeUpdate.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 3:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Good lord, guess we can never live down a simple spelling mistake. Jeeeshh.

This has been fixed in CVS for almost 3 weeks now...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 18, 2005 5:20 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
steve wrote:
Good lord, guess we can never live down a simple spelling mistake. Jeeeshh.

This has been fixed in CVS for almost 3 weeks now...

Steve, we should seriouly consider it as a legacy API and put in back... nah just kidding ;-)

_________________
Emmanuel


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.