Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Entity must be managed to call remove

 
Kshitiz Agarwal
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am facing a very common problem. I am not able to remove an entity from datatable. My entity class is:



My Dao class is:





My service class is:



And my spring-config xml file is:



What can be the reason behind this error:

Entity must be managed to call remove: com.infosys.ingreen.middleware.entity.ElectricDeviceEntity@908881, try merging the detached and try the remove again.
 
Vijitha Kumara
Bartender
Posts: 3953
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you get as the deviceEntity in the method? Perhaps you can try some changes to the entity in the memory then call deleteDevice() method to see whether you get the entity from the DB after the call to merge()?
 
Kshitiz Agarwal
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijitha Kumara wrote:What you get as the deviceEntity in the method? Perhaps you can try some changes to the entity in the memory then call deleteDevice() method to see whether you get the entity from the DB after the call to merge()?


I have checked that...even what I have searched that entity in deleteDeviceDao class and then remove that found entity. But again the same error is coming. I dont know why the entity is not managed entity here?
 
Kshitiz Agarwal
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijitha Kumara wrote:What you get as the deviceEntity in the method? Perhaps you can try some changes to the entity in the memory then call deleteDevice() method to see whether you get the entity from the DB after the call to merge()?


When I tried the following change:


@Repository
@Component




The error comes is:

Exception Description: No transaction is currently active


Please help me....any suggestion??
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!