java - Joining to a collection in a JPA-QL query -
i'am using jpa mapping ,i have entity class
@entity @table(name = "h_pe") @xmlrootelement @namedqueries({ 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; @joincolumn(name = "pe_platform", referencedcolumnname = "platform_name", insertable = false, updatable = false) @manytoone(optional = false) private hplatform hplatform; }
i want write request jpa following(i have wrote sql ),i have tried write haven't understood how use pe_env because result of onetomany relationship!
select distinct h_env.env_name,h_platform.platform_name h_env,h_platform,h_pe h_env.env_url=h_pe.pe_env , h_platform.platform_name=h_pe.pe_platform , h_platform.platform_name='xxx';
select e.name, p.name hpe hp join hp.hplatform p join hp.hpespcollection p p.name = 'xxx'
see, http://en.wikibooks.org/wiki/java_persistence/querying#common_queries
Comments
Post a Comment