delete « Batch « JPA Q&A





1. Batch Delete in Hibernate    coderanch.com

I did some groundwork on batch deletes in Hibernate and came across a useful link at Aaron Johnson's blog. I implemented the suggestion in the following manner: StringBuffer itemIdsForDelete = new StringBuffer(); // Convert the IDs into CSV format for( Iterator iter = pomItemIds.iterator(); iter.hasNext(); ) { itemIdsForDelete.append( iter.next() ); if( iter.hasNext() ) { itemIdsForDelete.append( " , " ); } } ...

2. Batch Delete using Hibernate Querry?    coderanch.com

Hi There, I am using this in my Configuration file --> org.hibernate.hql.classic.ClassicQueryTranslatorFactory I got a scenario where I need to execute delete * from Alerts where userid=? By using above Factory class I was unable to execute this querry, it keep says querry should start with from or select. If I replace this Factory with org.hibernate.hql.ast.ASTQueryTranslatorFactory, then this delete executes fine ...

3. Batch deletion    forum.hibernate.org

Is there another way to excecute batch delettion such as a HSQL like: delelet pack.AnEntity where pack.AnEntity.aProperty > 0 ? The method delete(String query) provided by the session implementation seems not to do the deletion effetively. First, it finds all entities according to the query and then deletes them one by one. Secondly, the find(String query) will load all propertis of ...

4. how Can I do batch delete in hibernate    forum.hibernate.org

5. Trouble using batch delete with paramater substitution    forum.hibernate.org

String deleteQueryString = "from " + Database.NAME_OF_STATE + " e where e.timestamp <= ?"; // Delete the requested entries session.delete( ...

6. Batch delete with Hibernate 3 ?    forum.hibernate.org

Hello, I allways used the deprecated delete(String) method when I needed to delete several object at once... Now, to conform to the version 3 API, how must I do to achieve my goal ? I thought it could be : session.createQuery("FROM AND WHERE clauses").list().clear(); but it does not work (nothing is deleted from the database). Is it a problem with my ...

7. batch: insert, update or delete failed    forum.hibernate.org

I have a bidirectional relationship like this. Code: ... ...

8. About batch update/delete/insert in Hibernate    forum.hibernate.org

Hi all, I am using hibernate 2.1.4, manipulating a grape of POJOs. All having a "version" property for pessimistic locking. What I want to know is how batch update/delete/insert can be activated in hibernate? Is it done automatically? Does it work with POJOs having "version" property? best regards Mohammed [b]Hibernate version: 2.1.4[/b] [b]Name and version of the database you are using: ...

9. Facing problem with batch delete    forum.hibernate.org

Hello All , I am facing problem with batch delete. I read on the forum that batch delete doesn't need from clause and doesn't work with alias. When i tried it with from clause it was throwing NullpointerException. After reading on forum i removed from clause. But now i am facing SQLGrammerException. So can anybody tell me how should i write ...





10. Batch Delete Problem    forum.hibernate.org

Full stack trace of any exception that occurs: Caused by: org.hibernate.QueryException: query must begin with SELECT or FROM: delete [delete com.dxic.farm.test.service.bo.NoticeAttachment where attachmentID = '8a85e425077d300001077d3462b0000c'] at org.hibernate.hql.classic.ClauseParser.token(ClauseParser.java:83) at org.hibernate.hql.classic.PreprocessingParser.token(PreprocessingParser.java:108) at org.hibernate.hql.classic.ParserHelper.parse(ParserHelper.java:28) at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:175) at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:151) at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:473) at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1032) at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1013) at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:89) at com.farm.springframework.dao.impl.BaseDao.executeUpdate(BaseDao.java:252) ... 28 more org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session is disconnected at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:59) ...

11. Batch delete    forum.hibernate.org

for (NodeElement node : deleteCandidates){ Query query = this.entityMgr.createNativeQuery("delete from node where id = :id"); query.setParameter("id", node.getId()); query.executeUpdate(); if (++i % FLUSH_SIZE == 0){ entityMgr.flush(); entityMgr.clear(); } } ...

12. Batch delete fails and individual delete statements issued    forum.hibernate.org

Hibernate version: 3.2 Problem/Question: How can I issue bulk deletes so that all entries in the associate link table as well as the row in the target table is deleted? I want to delete all entries in the EventPersonLink table that correspond to a particular Event as well as that specific Event. My database mapping: Person --- EventPersonLink --- Event where ...

13. Batch update mixing insert/deletes/updates    forum.hibernate.org