users@glassfish.java.net

Re: selecting data using Embedded Entity

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Thu, 10 Dec 2009 10:21:20 -0800

Does "where m.id.emp_grp = 'grp'" work?


glassfish_at_javadesktop.org wrote:
> Sorry, really new to JPA.
>
> I have an Embedded ID class used as the primary key. How do I select data only using one of the fields in the key??
>
> I have two fields in the EmployeePK: (emp_grp, hire_date). emp_grp and hire_date would be a unique record. I want to select all records with emp_grp.
>
> I can do this: "select m from Employee m where m.id = 'id'"
> But the id field is the EmployeePK class and I must also use the hire_date.
>
> I want something like this: select m from Employee m where m.emp_grp = "emp_grp"
> but the "m.emp_grp" field is not visible since its in the EmployeePK class.
>
> Thanks
> [Message sent by forum member 'larryl' ]
>
> http://forums.java.net/jive/thread.jspa?messageID=375802
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>