[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [eclipselink-users] Correct Way of Writing Generic Select All Query? (Here's how i did it)
|
Tim,
James filed a bug to address this requirement if you are interested in tracking it or contributing to the discussion of what the final solution might look like.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=229772
What you have done is fine but we should add a more elegant and less proprietary solution for this.
Doug
-----Original Message-----
From: Tim Hollosy [mailto:hollosyt@xxxxxxxxx]
Sent: Wednesday, April 30, 2008 1:40 PM
To: EclipseLink User Discussions
Subject: [eclipselink-users] Correct Way of Writing Generic Select All
Query? (Here's how i did it)
I noticed myself writing the same select all query over and over
again, here's how I made it generic.
This is a method in my "model" class (a class that holds an instance
of my EntityManager)
public List<?> selectAll(Class<?> clazz)
{
JpaEntityManager jpaEm = JpaHelper.getEntityManager(getEntityManager());
Query query = jpaEm.createQuery(null, clazz);
return query.getResultList();
}
So I'm basically creating a new query with a null expression, this way
I'm not writing boiler plate Select queries. Is there a more elegant
way of doing it though?
--
./tch
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users