From: David B. (JIRA) <no...@at...> - 2005-12-18 13:04:58
|
Non lazy loaded List updates done in wrong order, cause exception ----------------------------------------------------------------- Key: HHH-1296 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1296 Project: Hibernate3 Type: Bug Components: core Versions: 3.0.5 Environment: Hibernate 3.0.5 - any database (checked postgres 7/8, mysql 4 & 5, db2 v8) NOT using lazy loading - the tx's are wrapped by session beans, so lazy loading is not allowed. Reporter: David Birch Priority: Critical The logic behind list updates is not quite right, nor was it in v2 (only now i have a DBA who won't let up...) The scenario is: a bean with list property, and the list has a number of items in it (say 4, index 0-3), an item is then removed (say item at index 2), and the bean is requested to be saved. From what i can see in the SQL traces, the same statements are issues whe lazy loading is on or off, they are: [18/12/05 19:48:50:766 EST] 00000036 SystemOut O Hibernate: delete from TGE_CLIENT_POLICY where CLIENT_ID=? and POSITION=? [18/12/05 19:48:50:766 EST] 00000036 SystemOut O Hibernate: update TGE_CLIENT_POLICY set POLICY_NK=? where CLIENT_ID=? and POSITION=? So, i can only assume (as when this fails, the row with index 1 above the removed row is nuked!), hibernate removes the item at index 3, and then copies the value of the item at index 3 onto the row for item at index 2. Fair enough but... When i have lazy loading off, i get DB exceptions like Duplicate key or integrity constraint violation message from server: "Duplicate entry '1-999999' for key 1" so, there is some nasty in there, which is not updating the correct row - this has happened since 2.1.8 that i know of :( i will try & look @ the source, but won't get a chance until after xmas... -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: David B. (JIRA) <no...@at...> - 2005-12-18 13:42:58
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1296?page=comments#action_21327 ] David Birch commented on HHH-1296: ---------------------------------- Arrrg, that post was a little in-complete...what i failed to include is- (a) i am actually just trying to keep a collection of Strings, in order, attached to a bean, hence i wanted to use list. (b) i have been given a constraint by a DBA who is enforcing that the parent id & string value form the primary key, not the parent id & index value - that ebing said, i do think this is a very common type of scenario. i am pretty sure that what i want to do is ok, just that there is something busted with the non-lazy loaded list :( > Non lazy loaded List updates done in wrong order, cause exception > ----------------------------------------------------------------- > > Key: HHH-1296 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1296 > Project: Hibernate3 > Type: Bug > Components: core > Versions: 3.0.5 > Environment: Hibernate 3.0.5 - any database (checked postgres 7/8, mysql 4 & 5, db2 v8) > NOT using lazy loading - the tx's are wrapped by session beans, so lazy loading is not allowed. > Reporter: David Birch > Priority: Critical > > > The logic behind list updates is not quite right, nor was it in v2 (only now i have a DBA who won't let up...) > The scenario is: > a bean with list property, and the list has a number of items in it (say 4, index 0-3), an item is then removed (say item at index 2), and the bean is requested to be saved. > From what i can see in the SQL traces, the same statements are issues whe lazy loading is on or off, they are: > [18/12/05 19:48:50:766 EST] 00000036 SystemOut O Hibernate: delete from TGE_CLIENT_POLICY where CLIENT_ID=? and POSITION=? > [18/12/05 19:48:50:766 EST] 00000036 SystemOut O Hibernate: update TGE_CLIENT_POLICY set POLICY_NK=? where CLIENT_ID=? and POSITION=? > So, i can only assume (as when this fails, the row with index 1 above the removed row is nuked!), hibernate removes the item at index 3, and then copies the value of the item at index 3 onto the row for item at index 2. Fair enough but... > When i have lazy loading off, i get DB exceptions like > Duplicate key or integrity constraint violation message from server: "Duplicate entry '1-999999' for key 1" > so, there is some nasty in there, which is not updating the correct row - this has happened since 2.1.8 that i know of :( > i will try & look @ the source, but won't get a chance until after xmas... -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Nigel W. (JIRA) <no...@at...> - 2006-06-08 09:05:33
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1296?page=comments#action_23300 ] Nigel White commented on HHH-1296: ---------------------------------- Yes! I'm getting this too when I remove() an entry from a List with an @IndexColumn. The problem is the way Hibernate creates the link table, and then updates the link table. It puts a "unique" constraint on the child key of the link. That's a problem for a start, it means that a linked-to entity can only be a meber of one List. Try to put it into the List of another parent, and you'll get this error. It's a problem on List.remove() because the way it deals with removes is it cuts down the size of the list by deleting excess link rows from the end. That's fine - a perfectly good start. But then it just goes down the remaining link rows from 0 to n, updating them to point to the new List entries. If List item entry 0 was removed, then when it updates link row 0 to point to what link row 1 pointed to, bzzzzzzt... constraint violation, duplicate key! The schema update should not put the unique constraint on the child key of the link table! > Non lazy loaded List updates done in wrong order, cause exception > ----------------------------------------------------------------- > > Key: HHH-1296 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1296 > Project: Hibernate3 > Type: Bug > Components: core > Versions: 3.0.5 > Environment: Hibernate 3.0.5 - any database (checked postgres 7/8, mysql 4 & 5, db2 v8) > NOT using lazy loading - the tx's are wrapped by session beans, so lazy loading is not allowed. > Reporter: David Birch > Priority: Critical > > > The logic behind list updates is not quite right, nor was it in v2 (only now i have a DBA who won't let up...) > The scenario is: > a bean with list property, and the list has a number of items in it (say 4, index 0-3), an item is then removed (say item at index 2), and the bean is requested to be saved. > From what i can see in the SQL traces, the same statements are issues whe lazy loading is on or off, they are: > [18/12/05 19:48:50:766 EST] 00000036 SystemOut O Hibernate: delete from TGE_CLIENT_POLICY where CLIENT_ID=? and POSITION=? > [18/12/05 19:48:50:766 EST] 00000036 SystemOut O Hibernate: update TGE_CLIENT_POLICY set POLICY_NK=? where CLIENT_ID=? and POSITION=? > So, i can only assume (as when this fails, the row with index 1 above the removed row is nuked!), hibernate removes the item at index 3, and then copies the value of the item at index 3 onto the row for item at index 2. Fair enough but... > When i have lazy loading off, i get DB exceptions like > Duplicate key or integrity constraint violation message from server: "Duplicate entry '1-999999' for key 1" > so, there is some nasty in there, which is not updating the correct row - this has happened since 2.1.8 that i know of :( > i will try & look @ the source, but won't get a chance until after xmas... -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Thomas W. (JIRA) <no...@at...> - 2006-07-19 15:26:59
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1296?page=comments#action_23667 ] Thomas Weber commented on HHH-1296: ----------------------------------- The same problem also occurs, if a List is fetched LAZY. This is a real show stopper. > Non lazy loaded List updates done in wrong order, cause exception > ----------------------------------------------------------------- > > Key: HHH-1296 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1296 > Project: Hibernate3 > Type: Bug > Components: core > Versions: 3.0.5 > Environment: Hibernate 3.0.5 - any database (checked postgres 7/8, mysql 4 & 5, db2 v8) > NOT using lazy loading - the tx's are wrapped by session beans, so lazy loading is not allowed. > Reporter: David Birch > Priority: Critical > > > The logic behind list updates is not quite right, nor was it in v2 (only now i have a DBA who won't let up...) > The scenario is: > a bean with list property, and the list has a number of items in it (say 4, index 0-3), an item is then removed (say item at index 2), and the bean is requested to be saved. > From what i can see in the SQL traces, the same statements are issues whe lazy loading is on or off, they are: > [18/12/05 19:48:50:766 EST] 00000036 SystemOut O Hibernate: delete from TGE_CLIENT_POLICY where CLIENT_ID=? and POSITION=? > [18/12/05 19:48:50:766 EST] 00000036 SystemOut O Hibernate: update TGE_CLIENT_POLICY set POLICY_NK=? where CLIENT_ID=? and POSITION=? > So, i can only assume (as when this fails, the row with index 1 above the removed row is nuked!), hibernate removes the item at index 3, and then copies the value of the item at index 3 onto the row for item at index 2. Fair enough but... > When i have lazy loading off, i get DB exceptions like > Duplicate key or integrity constraint violation message from server: "Duplicate entry '1-999999' for key 1" > so, there is some nasty in there, which is not updating the correct row - this has happened since 2.1.8 that i know of :( > i will try & look @ the source, but won't get a chance until after xmas... -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |