I would like to do a select that joins two tables by id (j.id = m.jobId) and get a single value (j.name) that will be single object. When I make a join call, I get an array of objects. I need to pass a single type of object to a DisplayTag page. What is the best way to do this?
if you are using Criteria you can use projections to select only one field from the query,
if you are using HQL you can say
posted 8 years ago
Anantha, thanks so much for your reply. I have been unable to set that value in the object that I need to pass on to a page. In the example below, I have two objects. The join is at id/jobId. jobName is the value I want to set though it isn't an actual column in the database. I just need to display the job name with the module information. When I do a join in Hibernate, I get an array of objects whereas I need only of type Module but with the value "jobName" set from the join to Job. Is that possible? I may be missing something in your example but since I need values from two tables but only want to create a list of objects of one type, how do get just the single value from Job without adding objects of type Job to the list?
All that thinking. Doesn't it hurt? What do you think about this tiny ad?
Two software engineers solve most of the world's problems in one K&R sized book