java - JPA enity has three times this same relation -


i have 2 simple models:

public class wallet{     @id     @generatedvalue(strategy = generationtype.auto)     @column(name = "wallet_id")     private long walletid;      @column(name = "owner_label")     private string ownerlabel;      @column(name = "user_id")     private long userid; } 

and

public class transfer{      @id     @generatedvalue(strategy = generationtype.auto)     @column(name = "transfer_id")     private long transferid;      @notnull     @column(name = "amount")     private bigdecimal amount = bigdecimal.zero;      @manytoone(fetch = fetchtype.lazy)     @joincolumn(name = "owner_wallet_id")     private wallet ownerwallet;      @manytoone(fetch = fetchtype.lazy)     @joincolumn(name = "from_wallet_id")     private wallet fromwallet;      @manytoone(fetch = fetchtype.lazy)     @joincolumn(name = "to_wallet_id")     private wallet towallet; } 

the problem when want transfer relations (wallets) in 1 query

select t transfer t  left join fetch t.ownerwallet w  left join fetch t.towallet tw  left join fetch t.fromwallet fw  w.userid = :userid order t.createdat desc 

i exception mysqlintegrityconstraintviolationexception: duplicate entry '2' key 'primary' have soultion? in advise

i'm pretty sure getting error when trying insert data , have primary key duplicate. mysqlintegrityconstraintviolationexception constraint violation in db model, nothing selecting data.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -