jpa - Hibernate doesn't persist a OneToOne modification -


here simplified code related bug:

@entity @table(name = "ms_filter", uniqueconstraints=@uniqueconstraint(columnnames = { "ms_id" })) public class msfilter  @onetoone private ms ms; 

you ca see there constraint on ms_id.

a new instance of class created. ms field set value (a ms) sqlid (it's primary key) equals "1649809", field mapped ms_id. @ time there msfilter pointing same ms, both instances have been committed long date.

then change value of field ms ms sqlid equals 1618544 (a new ms in session). is done reflection, setter method invoked.

then commit called. can see hibernate tries save new entity old value ms. here logs i've added before commit. msfilters instances of session listed (i've put logs in constructor check this).

ref: [1] ms_id 1649627 filter_id 1657507 unique_key -2011976030:-1667727498:3:6 user_id null user_profile null id 1657509

ref: [2] ms_id 1649809 filter_id 1657507 unique_key 13321113:-1720593839:2:3076 user_id null user_profile null id 1659533

current: [3] ms_id 1618362 filter_id 1626084 unique_key 1196133270:-1667727498:3:6 user_id null user_profile null id 1628109

current: [4] ms_id 1619159 filter_id 1626084 unique_key 1196133270:-1667727498:1:2 user_id null user_profile null id 1628108

current: [5] ms_id 1618544 filter_id 1626084 unique_key 1196133270:null user_id null user_profile null id 1659620

i did activate hibernate logs , here first , sql statement:

2015-04-01 01:55:53 debug sql:109 - insert ms_filter (ms_id, filter_id, unique_key, user_id, user_profile, id) values (?, ?, ?, ?, ?, ?)

2015-04-01 01:55:53 trace basicbinder:81 - binding parameter [1] [integer] - [1649809]

2015-04-01 01:55:53 trace basicbinder:81 - binding parameter [2] [integer] - [1626084]

2015-04-01 01:55:53 trace basicbinder:81 - binding parameter [3] [varchar] - [1196133270:null]

2015-04-01 01:55:53 trace basicbinder:69 - binding parameter [4] [varchar] - [null]

2015-04-01 01:55:53 trace basicbinder:69 - binding parameter [5] [varchar] - [null]

2015-04-01 01:55:53 trace basicbinder:81 - binding parameter [6] [integer] - [1659620]

as can see hibernate tries insert instance [5] (if consider "id" column). value "ms_id" not 1 ? , of course unique constraint not respected , transaction fails.

what cause ?


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -