Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] OneToMany unidirectional with composite PK

Please can you help me. I would like to have OneToMany unidirectional with composite PK.

Code:

public class UEmployee extends DataWithPropertyChange.Abstract implements Serializable, Cloneable {

    @Id
    @Column(name = "ID")
    private int id;

    @OneToMany(mappedBy = "employee", cascade = { CascadeType.MERGE/*, CascadeType.REMOVE*/, CascadeType.DETACH, CascadeType.PERSIST, CascadeType.REFRESH})
    @OrderBy("dataType, azimuthDeg")
    @PrivateOwned
    private List<UData> dDataCollection;
}

// composite PK: dataType, azimuthDeg, employee
public class UData {

    @Id
    @Column(name = "DATA_TYPE", nullable = false)
    private int dataType;

    @Id
    @Column(name = "AZIMUTH", precision = 4, scale = 0)
    private float azimuthDeg;

    @Id
    @JoinColumn(name = "ID", referencedColumnName = "ID")
    @ManyToOne
    private UEmployee employee;

    @Column(name = "DVALUE", precision = 4, scale = 0)
    private float value;
}


I'm using latest release: Eclipselink 2.1.0.v20100614-r7608.

I can't use @JoinColumn because I get exception that I have to use @JoinColumns with all PK columns.

I would like to remove field 'UData.employee' and replace it with unidirectional mapping. Is it possible?

Thank you very much for help.


Back to the top