-->
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.  [ 4 posts ] 
Author Message
 Post subject: entity's table name for straight SQL query
PostPosted: Tue Jul 27, 2004 10:01 am 
Newbie

Joined: Mon Feb 09, 2004 6:45 pm
Posts: 10
Location: Feltre, BL Italy
I'm writing a stad-alone (SWT) application using Hibernate 2.1 + Spring framework 1.0.2. DB is MySQL Server.

What I want to do is a "massive" delete of some table's rows.
I know that in hibernate I do not have to use
session.delete(Collection) because this will try to
incarnate all table rows, then delete each single row from the table:
this is a memory hog and very time consuming task, isn't it?

Alternative is using straight SQL this way:

public class RemovedCustomerDaoHibernateImpl extends HibernateDaoSupport {

public void deleteAll() throws Exception {
String deleteStatementString = "DELETE * from <tablename>";

Session hibernateSession = super.getHibernateTemplate().getSessionFactory().openSession();
Statement statement = hibernateSession.connection().createStatement();
statement.execute(queryString);

return;
}

}

HibernateDaoSupport comes from the Spring framework.
My question is: can Iget the <tablename> string somehow
from Hibernate? This would allow me to change the db mappings
(the table name) w/o changing the code (deleteAll method).

Does this makes sense?
thanks
davide


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 10:43 am 
Newbie

Joined: Mon Feb 09, 2004 6:45 pm
Posts: 10
Location: Feltre, BL Italy
was this problem so odd/silly or whatever?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 10:46 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You can get it from the Configuration object.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 11:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Or use this http://www.gloegl.de/26.html evil hack without any warranties.


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