How can I retrieve the environment names by given Platform names using JPA request (1 environment can be associated to n Plateform and 1 Platform can be associated to n Environmnt)?
public class HPe implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
protected HPePK hPePK;
@Column(name = "PE_TIMEOUT")
private Integer peTimeout;
@Column(name = "PE_STATUS")
private Boolean peStatus;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "hPe")
private Collection<HPesp> hPespCollection;
@JoinColumn(name = "PE_ENV", referencedColumnName = "ENV_URL", insertable = false, updatable = false)
@ManyToOne(optional = false)
private HEnv hEnv; // HEnv classe name
@JoinColumn(name = "PE_PLATFORM", referencedColumnName = "PLATFORM_开发者_开发技巧NAME", insertable = false, updatable = false)
@ManyToOne(optional = false)
private HPlatform hPlatform; //HPlatform classe name
}
Update problem Resloved :
SELECT h.hPePK.peEnv FROM HPe h WHERE h.hPePK.pePlatform = :w
Please try
select hpe.hEnv.envName from HPe hpe where hpe.hPlatform.platName = :platName
(Use platName
as parameter)
Maybe it needs something more like a join
but please try first
精彩评论