Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[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


Back to the top