openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cheng Zhang" <chzh...@yahoo-inc.com>
Subject unexpected update when using many to many relationship
Date Thu, 04 Mar 2010 17:37:47 GMT
Hi,

 

I found that, if I use many-to-many relationship, there will be
unexpected update when the transaction is closed.

 

Here is my code,

 

@Entity

@Table(name = "MC_SUBJECT")

public class Subject implements Serializable {

    @Id

    @Column(length=64)

    private String id;

 

    @Column

    private Date createdDate;

 

    @Column

    private String createdBy;

 

    @Column(length=128, nullable=false)

    private String title;

 

    @Column(length=128, nullable=false)

    private String subjectType;

 

    @Column(length=2048)

    private String description;

 

    @Column

    private Date modifiedDate;

 

    @Column

    private String modifiedBy;

 

    @ManyToMany(fetch=FetchType.LAZY)

    @JoinTable(name = "MC_CHILD_SUBJECT", joinColumns = {
@JoinColumn(name = "SUBJECT_KEY") }, inverseJoinColumns = {
@JoinColumn(name = "CHILD_SUBJECT_KEY") })

    private List<Subject> childSubjectCollection;

 

...... getters and setters

}

 

In my code, I just read some Subject records. In the log file, I can see
some update statement.

 

However, if I change the many-to-many to one-to-many, everything is fine
and no update.

 

Is it expected behavior?

 

Thanks,

 

Cheng

 

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message