Hi,
I'd like to set up this:
@Entity @Table(name = "A", uniqueConstraints = {}) @org.hibernate.annotations.Table(appliesTo = "B", indexes = {}) @SecondaryTable(name = "AA", pkJoinColumns = {@PrimaryKeyJoinColumn(columnDefinition = "A_ID", name = "A_ID")}) class A { @Column(name = "A_1", nullable = false) Integer a1;
@Column(name = "A_1", table = "AA", nullable = false) private Integer aa1;
public void setVirtualRamInMb(final Integer n) { this.a1 = n; this.aa1 = n; } @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "A_B", joinColumns = {@JoinColumn(name = "A_ID")}, inverseJoinColumns = {@JoinColumn(name = "B_ID")}) List<B> bs; }
@Entity @Table(name = "B") @SecondaryTable(name = "A_B", pkJoinColumns = {@PrimaryKeyJoinColumn(columnDefinition = "B_ID", name = "B_ID")}) @org.hibernate.annotations.Table(appliesTo = "B") class B { @Column(name = "b1", nullable = true) private long b1;
@Column(name = "ab1", table = "A_B", nullable = true) private long ab1;
public void setSize(final long n) { this.b1 = n; this.ab1 = n; }
@ManyToMany(mappedBy = "bs", fetch = FetchType.LAZY) private List<A> as; }
when creating a B object and adding it to a A object, in the table A_B I end up with two results instead of one. In one the relation is ok but the ab1 is 0 (default) in the other the relation with A is null but ab1 is ok.
Is this the expected behavior?
PS: I can provide a simple example (maven) with a main to show it up.
Thanks.
Regards.
ssedano.
|