Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Selecting data using EmbeddedID(how to select data using a field in the EmbeddedID class)
Selecting data using EmbeddedID [message #503062] Thu, 10 December 2009 17:55 Go to next message
Larry  is currently offline Larry Friend
Messages: 30
Registered: December 2009
Member
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
Re: Selecting data using EmbeddedID [message #503164 is a reply to message #503062] Fri, 11 December 2009 04:07 Go to previous message
Doug Clarke is currently offline Doug ClarkeFriend
Messages: 155
Registered: July 2009
Senior Member
You should simply navigate to the fielkds you want within the embedded id class:

select m from Employee m where m.id.emp_grp = "emp_grp"

Doug
Previous Topic:JPA NamedQuery Result
Next Topic:Exception while using static weaving
Goto Forum:
  


Current Time: Tue Mar 19 03:09:36 GMT 2024

Powered by FUDForum. Page generated in 0.02167 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top