IntelliJ Java IDE
The moose likes Object Relational Mapping and the fly likes Entity must be managed to call remove Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Entity must be managed to call remove" Watch "Entity must be managed to call remove" New topic
Author

Entity must be managed to call remove

ksh agarwal
Greenhorn

Joined: Dec 15, 2011
Posts: 22
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

Joined: Mar 24, 2008
Posts: 3563

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()?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
ksh agarwal
Greenhorn

Joined: Dec 15, 2011
Posts: 22
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?
ksh agarwal
Greenhorn

Joined: Dec 15, 2011
Posts: 22
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??
 
 
subject: Entity must be managed to call remove
 
Threads others viewed
XML name space error in Spring data JPA hibernate applicationContext.xml
The matching wildcard is strict, but no declaration can be found for element 'context:annotation'
Dependency injection problem
I am getting org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity:
HibernateDaoSupport and Transaction
Two Laptop Bag