java ee - EclipseLink: Value of Column is null while Deleting in ManyToMany-Relationship -


i have problem 1 of entities.

there 3 tables (useraccount, userrole, role) glassfish access management , 2 entities useraccount , role mapped "manytomany" each other.

to change roles of useraccount, apply new list of chosen roles via setroles()-method of useraccount. when add new roles, works fine, statement correct:

insert userrole (role_rolename, useraccount_email,                              useraccount_account_accountid)      values ('client', 'email@example.com', 1) 

but when remove item list, removed entry in join table should removed. expected, there query submitted email column set "null".

delete userrole ((role_rolename = 'administrator')      , ((useraccount_account_accountid = 1) , (useraccount_email = null))) 

has idea why column set null? when output email useraccount.getemail() right after , before merge database, returns email adress...

any appreciated.

thanks, manuel

setup: container: glassfish 3.1.2 jpa: eclipse persistence services - 2.3.2.v20111125-r10461

useraccount entity:

@entity @table(name="useraccount") @primarykeyjoincolumn(name = "account_accountid") public class useraccount extends account implements serializable {   private static final long serialversionuid = 1l;    private string password;    //bi-directional one-to-one association account   @onetoone   @joincolumn(name="account_accountid")   private account account;    @column(name="email")   private string email;    //bi-directional many-to-many association role   @manytomany   @jointable(     name="userrole"     ,      joincolumns={          @joincolumn(name="useraccount_email", referencedcolumnname="email"),         @joincolumn(name="useraccount_account_accountid", referencedcolumnname="account_accountid")         }     , inversejoincolumns={         @joincolumn(name="role_rolename")         }     )   private list<role> roles;               //getter , setters 

account entity

@entity @table(name="account") @inheritance(strategy=inheritancetype.joined) public abstract class account implements serializable {    private static final long serialversionuid = 1l;     @id    @generatedvalue(strategy=generationtype.identity)    private int accountid;     private boolean active;     private string address;     private string dtype;     private string firstname;     private string handy;     private string name;     private string tel;         //getter , setters 

role entity:

@entity @table(name="role") public class role implements serializable {     private static final long serialversionuid = 1l;      @id     @generatedvalue(strategy=generationtype.identity)     private string rolename;      @lob     private string roledescription;      //bi-directional many-to-many association useraccount     @manytomany(mappedby="roles")     private list<useraccount> useraccounts;      //getter , setters  

your model seems confused.

if useraccount subclass of account, account, should not have onetoone account?

email not part of account id cannot be, , not required join column in join table. need account id.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -