I have two tables like below. First one is a general parameter table. Second table is the server data table.
Code:
PARAMETER
ID CODE VALUE DESCRIPTION
1 PLATFORM 1 Core
2 PLATFORM 2 Remote
3 ENVRNMNT 1 Dev
SERVER
ID NAME PLATFORM
1 serv1 1
2 serv2 2
**SERVER.PLATFORM** column references **PARAMETER.VALUE** column, only for **PARAMETER.CODE = 'PLATFORM'**. Is there a way to implement Filter on a ManyToOne relation? Is there a way to make this work for example:
Code:
@Table(name="PARAMETER", schema = "PRM")
public class Parameter implements Serializable{
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "ID", unique = true, nullable = false, precision = 10, scale = 0)
private String id;
@Column(name = "CODE", length = 30)
private String code;
@Column(name = "VALUE", length = 30)
private String value;
@Column(name = "DESCRIPTION", length = 30)
private String description;
}
@Table(name="SERVER", schema = "PRM")
public class Server implements Serializable{
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "ID", unique = true, nullable = false, precision = 10, scale = 0)
private String id;
@Column(name = "NAME", length = 30)
private String name;
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name="PLATFORM", referencedColumnName="VALUE")
@Filter(name = "parameter_platform", condition = "CODE='PLATFORM'")
private Parameter platform;
}
Thanks.