Truncate « Table « JPA Q&A





1. Using hibernate/hql to truncate a table?    stackoverflow.com

What is the recommended way to truncate a table using hibernate/hql? I've tried this:

 Query query = session.createQuery("truncate table MyTable");
 query.executeUpdate();
But it didn't work (truncate doesn't seem do be documented anywhere in ...

2. Hibernate + Truncate a table    coderanch.com

Hello, I am a little bit newbie with hibernate. Here is my doubt, I want to Truncate a table, (delete all rows) and add an arraylist of objects to the this table. Like a replace Here is my code public void modificarPersona(List listaRecibida) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); try { PreparedStatement ps = session.connection().prepareStatement( "TRUNCATE TABLE persona"); ps.executeUpdate(); PersonaDTO personaDTOmodificar; ...

3. Truncate Tables    forum.hibernate.org

4. Problem when trying to truncate all tables    forum.hibernate.org

public class DatabaseSteps extends AbstractSeleniumSteps { public static final String FOREIGN_KEY_DISABLE = "/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;"; public static final String FOREIGN_KEY_ENABLE = "/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;"; ... public void initialiseDatabase() throws Exception { Transaction trans = session.beginTransaction(); ...