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,
You’re trying to store a
java.lang.Classobject, rather than an entity instance.transientInstanceis not an entity instance. It’scom.mypkg.pojo.Details.class.The error is in code that you don’t show, before the call to
save().