I'm using maven multimodule project. I divided my logic into different layers, Presentation, Business logic, data layer, each one in a separate module(layer). When I try to insert an object, this exception occurs:
org.hibernate.MappingException: Unknown entity: com.xxxxx.service.model.Object$Proxy$_$$_WeldClientProxy
How is this caused and how can I solve it?
I'm using CDI bean and the application is based on JSF2 and Hibernate.
This problem will happen when you have a JPA entity which is also declared as a CDI managed bean like below:
And you attempt to persist the CDI managed bean instance itself like below:
This is not the correct way. You should not make your entity a CDI managed bean. A CDI managed bean is actually a proxy class. You can clearly see this back in your exception message. It says it doesn't know the entity
com.xxxxx.service.model.Object$Proxy$_$$_WeldClientProxyinstead of that it doesn't know the entitycom.xxxxx.service.model.Object.And you should prepare it as a normal entity instance and then you can safely persist it as a normal entity.