Reputation: 45
I have below method to save an object to database using Hibernate but I keep getting "org.hibernate.MappingException: Unknown entity: java.lang.Class" error while saving.
System.out.println("transientInstance:" + transientInstance);
System.out.println("transientInstance:" + transientInstance.getClass());
getSession().save(transientInstance);
System.out.println statements are printing below information.
transientInstance:class com.mypkg.pojo.Details
transientInstance:class java.lang.Class
Any idea what could be wrong please?
Thanks,
Upvotes: 1
Views: 769
Reputation: 692171
You're trying to store a java.lang.Class
object, rather than an entity instance. transientInstance
is not an entity instance. It's com.mypkg.pojo.Details.class
.
The error is in code that you don't show, before the call to save()
.
Upvotes: 3