• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help required on the entityManager remove() method

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

I am currently working on the CRUD operation using JPA. While deleting an entity from the database, it is consuming a bit long time to complete the transaction. I have used entityManager.remove(entity) api. Since, the entity which I need to delete is having relation with other entities, all the references needs with those entities need to be deleted and hence it is taking so much of time. So is there any performance tricks can I implement to faster this deletion process?

Please help me

Thanks,
Keerthi Kumar N
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would start by getting an SQL log of what is really occurring (log level to FINE if using EclipseLink).

If you are deleting a lot of the same types of objects, batch writing may help.

http://java-persistence-performance.blogspot.com/2013/05/batch-writing-and-dynamic-vs.html

Otherwise, if you are deleting a dependency tree you could try CASCADE DELETE on the database.

See,
http://wiki.eclipse.org/EclipseLink/Examples/JPA/DeleteCascade

EclipseLink also has a @DeleteAll optimization for private OneToMany relationships.

If you are deleting a large batch of objects, you could use a JPQL bulk delete,

http://en.wikibooks.org/wiki/Java_Persistence/JPQL#Delete_Queries
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The easiet way to achieve to deal is like you can have an cascade attribute defined where you establishing the relation. What cascade facilitates us when you have one to many relation ship between classes and the change made to the column need to be reflected among its dependencies is managed by cascade with ease. Cascade comes up with Cascade delete , save , update or delete orphan.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic