-->
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: Status of the bulk delete functionality.
PostPosted: Wed Mar 23, 2005 1:48 pm 
Newbie

Joined: Wed Dec 22, 2004 4:25 pm
Posts: 5
Hibernate version: 3.0 rc1
Name and version of the database you are using:Ms SQL Server 2000

There seems to be a number of posts on the subject of bulk deletes using Hibernate 3 rc1 however, all the answers do not seem to work.

The reccommended way to do this is to use the createQuery().executeUpate() functionality like the following.


String deleteByNavKeyQ = "delete from SecurityGroupLink sgl where sgl.Id.LinkKey = ?";

public int deleteByLinkKey(String linkKey) throws HibernateException {

Query q = getSession().createQuery(deleteByNavKeyQ).setString(1,linkKey);
return q.executeUpate();

}


This code errors with a nullpointerexception. This seems to be a common error.

Is this a bug? Am I doing it wrong?
If it is a bug, do you know the status?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 23, 2005 3:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
I just committed this working functionality into CVS (afaik, it was only really broke on DBs which did not allow the delete table name to be aliased).

I have never seen a NullPointerException occur from an attempt to perform a bulk delete, and considering you did not post any relevent information I guess I still haven't ;)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 29, 2005 9:13 am 
Newbie

Joined: Mon Sep 15, 2003 10:07 am
Posts: 8
Location: Stuttgart, Germany
I am also having problems to get my bulk deletes running while migrating from Hibernate 2.1 to 3.0 rc1. Database is DB2 or HSQL.

The NullPointerException seems to occur if the query contains a "from" token, because the ANTLR HQL/SQL Query Parser adds an additional implicit "from" AST node which results in the NPE (HqlSqlBaseWalker line: 2193).

Try to you use
Code:
String deleteByNavKeyQ = "delete SecurityGroupLink sgl where sgl.Id.LinkKey = ?";


as query string. This will bring you to the next problem (that's were I currently hang). I get a SQLGrammarException complaining about the table alias in the generated SQL statement.
But according to Steves replies (see also a question about Hibernate 3) I conclude that this issue was fixed in the meantime.

Regards,
Ralf


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.