java - update on many-to-one hibernate relationship no works -


i have problem hibernate relationship many-to-one.

my system commercial proposal controller, has responsible proposal user entity. when proposal create , set responsible, has no problems, works fine. when change responsible , update, changes object, can see in datatable, has no update in database. if refresh on page update disapears.

    @entity     @table(name = "proposal")     public class proposal implements serializable {      @id     @generatedvalue     private integer id;      @manytoone     private user responsible;    ............       

dao code

    public void update(proposal proposal) {     this.session.update(proposal);      } 

in user class don't make annotation relationship, it's unidirectional relationship. class proposal yet use user class make user's bag, participants, , relationship unidirectional relationship too.

i tried make annotations in user class no works too.

user class annotations

   @entity    @table(name="user")     public class user implements serializable{      @onetomany      private list<proposal> proposal; 

the class user has many-to-one relationship usertype , works fine.

    @entity     @table(name="user")      public class user implements serializable{      @manytoone(fetch = fetchtype.lazy)      @joincolumn(name = "idtype, nullable = true)      private tipousuario    usertype; 

someone has ideia this?

thanks

you'll see changes after flushing database. either manually - flush() or after transaction has been committed. user class - must either entity (both @entity , @id annotations needed) or embedable class , should configured in corresponding way in case.

i'm not sure how works if - @entity without @id user, try again:

  1. run flush user. if won't exception - persisatble object. should see in db/web application log files - sql insert query.
  2. commit transaction. updated value of user should committed.

if invoke refresh, before commit, changes lost.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -