Reputation: 11445
I have the following code. When I call remove, I pass in a proxy that I get from entityManager.getReference. But entity.getClass() fails. How do i get the class information of a proxy
public <T extends BaseEntity> void remove(T entity) throws RemoveException {
//get the actual object
entity = (T)getEntityManager().find(entity.getClass(), entity.getId());
//delete the object
getEntityManager().remove(entity);
}
Unknown entity: com.merc.domain.EventLog_$$_javassist_3; nested exception is java.lang.IllegalArgumentException: Unknown entity: com.merc.domain.EventLog_$$_javassist_3
org.springframework.dao.InvalidDataAccessApiUsageException: Unknown entity: com.merc.domain.EventLog_$$_javassist_3; nested exception is java.lang.IllegalArgumentException: Unknown entity: com.merc.domain.EventLog_$$_javassist_3
Upvotes: 1
Views: 688
Reputation: 14779
I might be wrong ... but actually you put your entity into the function, just to get its class and id to find it again and then delete it? I would guess just drop the line:
entity = (T)getEntityManager().find(entity.getClass(), entity.getId());
and it should work.
Upvotes: 2