jpa many to many child list not persisted -


i have senario there entity article, entity author , join table article_author. article , author have many many relationship ( on article can have many authors , author can have many articles). here entities classes : author class:

@entity @table(name="author") @namedquery(name="author.findall", query="select author a") public class author implements serializable {     private static final long serialversionuid = 1l;      @id     @column(name="author_code")     private string authorcode;      private string nom;      //bi-directional many-to-many association article     @manytomany(fetch=fetchtype.eager)     @jointable(         name="article_author"         , joincolumns={             @joincolumn(name="author")             }         , inversejoincolumns={             @joincolumn(name="art_ref")             }         )     private list<article> article;  }  //getters , setters + hashcode , equals methods 

article class :

@entity @table(name="article_test") @namedquery(name="articletest.findall", query="select articletest a") public class articletest implements serializable {     private static final long serialversionuid = 1l;      @id     @column(name="art_ref")     private string artref;      @column(name="art_titre")     private string arttitre;      //bi-directional many-to-many association autheurtest     @manytomany(mappedby="articletests", fetch=fetchtype.eager)     private list<autheurtest> autheurtests;   //getters , setters + hashcode , equals methods } 

and here code create article , attach 1 author (for testing) :

            //.....             autheurtest aut1 = new autheurtest();             autheurtest aut2 = new autheurtest();              aut1.setautheurcode("1");             aut1.setnom("aut1");             articlemodelbean.createautheurtest(aut1);             articletest art1 = new articletest();                        art1.setartref("a");             art1.setarttitre("art1");                    articlemodelbean.dmlarticle_test(art1,"insert"); //persist art1             autheurtest newaut = articlemodelbean.getauteuractive_test(aut1.getautheurcode());                        articletest  foundedart =  articlemodelbean.findarticle_test(art1.getartref()); //getting article                   foundedart.getautheurtests().add(newaut);                  articlemodelbean.artaut(foundedart); //merge foudedart         //.....              

so i'm not getting error, both article , author added database! foreign keys not inserted join table. author not attached article.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -