I figured it out.But Still I am looking for a nice book to start my JPA.
On Wed, Mar 23, 2011 at 8:02 PM, Sreekanth <sree...@gmail.com>wrote:
Environment used: MySQL, GF3.1
I have these 3 tables namely Users,Customers and Tasks in my database.
Users will be assigned some tasks.
A task will have a customer associated with it.
I am describing the tables ignoring the associations among them.The
associations I care about are above.
I have entities created by Netbeans for all the tables in database.Now I am
trying to execute a query which will give me some columns picked from
Customers table and tasks table.I am trying to just create a normal join
between these 2 tables, but I am stuck.I am trying this way:
@NamedQuery(name = "Task.findByUserId",query = "SELECT t.taskId,
"c.firstName,c.lastName,c.email FROM Task t , Customer c " +
"WHERE t.assignedTo.id= :assignedUserId AND
But it gets translated to :
Call: SELECT t0.TASK_ID, t0.TASK_DATE, t0.IS_COMPLETED, t0.TASK_DESCRIPTION, t1.FIRST_NAME, t1.LAST_NAME, t1.EMAIL FROM TASKS t0, CUSTOMERS t2, CUSTOMERS t1 WHERE (((t0.ASSIGNED_TO = ?) AND (t1.CUSTOMER_ID = )) AND (t2.CUSTOMER_ID = t0.CUSTOMER_ID))
What is the mistake I am doing here.Can some one correct me and also I
would like to enquire about some documentation or book which explains JPQL