mysql - Exception in thread "main" org.hibernate.TransientObjectException -
i have 2 classes employe(id,nom,solde...) , conge(id,duree,...)
use annotation , in test class put code update "solde" of de employee:
employe p=new employe(); p.getsolde(); p.setsolde(sol.sold(17,2)); da.updateemploye(p); but have error:
exception in thread "main" org.hibernate.transientobjectexception: given object has null identifier: metier.employe
usually org.hibernate.transientobjectexception when try save object without saving dependencies.
when have entity a contain entity b, should create entity b before can create entity a.
b b = new b(); session.save(b); a = new a(); a.setb(b); session.save(a); or can use cascade indicate hibernate save b when saving a
Comments
Post a Comment