JPQL and partial attributes [message #385305] |
Tue, 27 January 2009 07:47  |
Eclipse User |
|
|
|
Hi,
I would like to know if is possible to retrieve just some attributes of an
object using JPQL queries.
I tried to use something like:
Select SELECT j.jobStatus,j.application,j.server FROM JobEntity j WHERE
(j.application like 'application%' and j.server = 'server1')
In both EclipseLink and Derby logs I can see that all the columns, not
just the ones in the JPQL select are retrieved.
|
|
|
|
Re: JPQL and partial attributes [message #385311 is a reply to message #385309] |
Tue, 27 January 2009 08:26   |
Eclipse User |
|
|
|
ReadAllQuery query = new ReadAllQuery(AutoSysJob.class);
query.setJPQLString("SELECT job.jobName FROM AutoSysJob job "
+ "WHERE (job.jobName like 'job%' and job.server =
'server1')");
Object listJobs = read(query);
Where "read":
ClientSession cs = getEntityManager().getServerSession()
.acquireClientSession();
try
{
List<?> results = null;
...
results = (List<?>)cs.executeQuery(query);
}...
Generated SQL(eclipse link log)
[EL Fine]: 2009.01.27
08:21:10.187--ServerSession(33397577)--Connection(11819817)- -Thread(Thread[main,5,main])--SELECT
wcc_id, server_type, job_name, job_status, job_type, owner, preds, server,
as_lineage, as_appl, box_name, box_joid, exit_code, as_group, joid,
last_end_stamp, last_start_stamp, next_stamp, ntry, run_mach, run_num,
status_stamp, target_mach, timezone, def_mod, del FROM m_job WHERE
(((job_name LIKE job%) AND (server = server1)) AND (server_type = A))
|
|
|
|
Re: JPQL and partial attributes [message #385405 is a reply to message #385311] |
Wed, 28 January 2009 07:34  |
Eclipse User |
|
|
|
Why are you using the Session and ReadAllQuery?
You should just do,
List results = getEntityManager().createQuery("SELECT job.jobName FROM
AutoSysJob job WHERE (job.jobName like 'job%' and job.server =
'server1')").getResultList();
In the native API, ReadAllQuery only returns objects, if you use a
ReportQuery, you can select data, but you should not need to use the
native API.
In JPA you can also select the entire object and set a FetchGroup on the
query to only fetch some of the attributes.
---
James
http://www.nabble.com/EclipseLink---Users-f26658.html
|
|
|
Powered by
FUDForum. Page generated in 0.04056 seconds