-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem mit all,delete_orphan + Listensemantik?
PostPosted: Mon Mar 29, 2010 3:58 pm 
Beginner
Beginner

Joined: Mon Jan 04, 2010 2:52 pm
Posts: 30
I have an Entity Project:

Code:
public class Project {
[...]

@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
@org.hibernate.annotations.IndexColumn(name="indexcol_hitlists")
@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.ALL,
                          org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
private List<SequenceList> hitlists;

[...]


Manchmal wenn ich eine SequenceList ("hitlist") aus der hitlists
Collection entferne, und saveOrUpdate(project) aufrufe, dann bekomme ich:

Code:
  Violation of unique constraint SYS_CT_79: duplicate value(s) for column(s) HITLISTS_ID in statement [update projects_sequencelists set hitlists_id=? where projects_id=? and indexcol_hitlists=?]


=> hier ist die Debugausgabe:
Code:
Deleting rows of collection: [de.bhc.pepa.Project.hitlists#1]
about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
delete from projects_sequencelists where projects_id=? and indexcol_hitlists=?
Hibernate: delete from projects_sequencelists where projects_id=? and indexcol_hitlists=?
preparing statement
binding '1' to parameter: 1
binding '7' to parameter: 2
done deleting collection rows: 1 deleted
Updating rows of collection: de.bhc.pepa.Project.hitlists#1
about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
closing statement
about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
update projects_sequencelists set hitlists_id=? where projects_id=? and indexcol_hitlists=?
Hibernate: update projects_sequencelists set hitlists_id=? where projects_id=? and indexcol_hitlists=?
preparing statement
binding '7' to parameter: 1
binding '1' to parameter: 2
binding '1' to parameter: 3
about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
closing statement


=> diese beiden queries werden ausgeführt:
Code:
delete from projects_sequencelists where projects_id=1 and indexcol_hitlists=7;
update projects_sequencelists set hitlists_id=7 where projects_id=1 and indexcol_hitlists=1;


Das ist wirklich komisch: indexcol_hitlists=1 ist die SequenceList, die ich
vor dem saveOrUpdate aus der Collection entfernt habe. Die erste delete-query
hat scheinbar gar nichts damit zu tun...

Hat jemand noch Vorschläge, wie ich dies debuggen kann?

Was sind die Nachteile der Bagsemantik wenn ich schon überall Lazy
Fetching benutze: ist das nur, dass die Reihenfolge nicht garantiert ist?
Die Reihenfolge bekomme ich doch mit @OrderBy wieder hin (ich habe
ein Feld, das für die Sortierung geeignet ist)?

Vielen Dank,


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.