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
|
|