Al Salam Alaykom,
I'm trying to use hibernate annotation in one to many relation between Device and Positions Classes, one device has many positions. The problem that I'm getting a null list of positions when selecting the device, I tried a lot of solutions and nothing solve the problem
here's the relations part in my classes:
Device.java
@GwtTransient
private List<Position> positions = new LinkedList<Position>();
@OneToMany(mappedBy="device")
public List<Position> getPositions() {
return positions;
}
public void setPositions(List<Position> positions) {
this.positions = positions;
}
and Position.java
private Device device;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "device_id")
public Device getDevice() {
return device;
}
public void setDevice(Device device) {
this.device = device;
}
Also, I tried the following annotations:
//In Device:
@OneToMany(mappedBy = "device")
@LazyCollection(LazyCollectionOption.FALSE)
//In Position:
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({@JoinColumn(name = "device_id", insertable=false, updatable=false)})
/***********************************************************************************/
//In Device:
@OneToMany(mappedBy = "device",fetch = FetchType.EAGER)
@LazyCollection(LazyCollectionOption.FALSE)
@Fetch(FetchMode.SELECT)
//In Position:
@ManyToOne
@JoinColumn (name="device_id")
/***********************************************************************************/
//In Device:
@OneToMany(mappedBy = "device")
@LazyCollection(LazyCollectionOption.FALSE)
//In Position:
@ManyToOne
@PrimaryKeyJoinColumn
/***********************************************************************************/
//In Device:
@OneToMany(mappedBy = "device", cascade = javax.persistence.CascadeType.ALL, fetch=FetchType.EAGER)
@Fetch(FetchMode.SELECT)
@LazyCollection(LazyCollectionOption.FALSE)
//In Position:
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "device_id")
Any help will be appreciated... Thank you