persistence - How to save entity using MyBatis + Hibernate -
i'am using 2 framework , save data (mybatis fetch , hibernate save/update/delete). want entity mybatis , assign new entity , save hibernate
example :
i list of "role" through mybatis query. trying create new entity have mapping :
@manytoone(fetch = fetchtype.lazy, optional = false) @joincolumn(name = "id_role") private role role;
i doing setrole 1 of role list. call saveorupdate hibernate. exception :
object references unsaved transient instance - save transient instance before flushing
i understand exception there solution ?
thanks lot help.
the way how loading roles (via mybatis), hibernate doesn't know roles in database. exception see. way work around store roleid in entity instead of role object. alternatively, have load roles via hibernate, along entities use them.
Comments
Post a Comment