Home » Eclipse Projects » EclipseLink » JPQL and partial attributes
JPQL and partial attributes [message #385305] |
Tue, 27 January 2009 12:47 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Ana Tatavu![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=ana.tatavu%40yahoo.ca) Messages: 10 Registered: July 2009 |
Junior Member |
|
|
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.
Ana
|
|
| |
Re: JPQL and partial attributes [message #385311 is a reply to message #385309] |
Tue, 27 January 2009 13:26 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Ana Tatavu![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=ana.tatavu%40yahoo.ca) Messages: 10 Registered: July 2009 |
Junior Member |
|
|
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))
Ana
|
|
| |
Re: JPQL and partial attributes [message #385405 is a reply to message #385311] |
Wed, 28 January 2009 12:34 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
|
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
James : Wiki : Book : Blog : Twitter
|
|
|
Goto Forum:
Current Time: Sun Jan 19 18:01:48 GMT 2025
Powered by FUDForum. Page generated in 0.02956 seconds
|