Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Generics and Eclipselink
Generics and Eclipselink [message #389737] Thu, 25 June 2009 12:19 Go to next message
Enrico is currently offline EnricoFriend
Messages: 82
Registered: July 2009
Hi all. I am new in EclipseLink, so I hope my question wiil be not too
dummy :-)
I would like to know if there is an easy way to use generics and
eclipselink jpa in order to implement DAO for generics object. I know for
example that using Hibernate there is an HibernateDaoSupport that allow to
handle this. Is this possible using also eclipselink?
To be more clear, i would like to have something similar to y.html
but using eclipselink ORM.

Best Regards,
Re: Generics and Eclipselink [message #389745 is a reply to message #389737] Thu, 25 June 2009 14:19 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Should be pretty simple to do this.

Something like:
public abstract class BaseDAOJPA<T>
implements BaseDAO<T> {
public void save(T object) {

public T get(Serializable id) {
return getEntityManager().find(getModelClass(), id);

public void remove(T object) {

public void remove(Serializable id) {

public List<T> loadAll() {
return getEntityManager().createQuery("Select o from " +
getModelClass().getSimpleName() + " o");

protected abstract Class<T> getModelClass();


James : Wiki : Book : Blog : Twitter
Previous Topic:remove not removing
Next Topic:Order of persit operations not preserved?
Goto Forum:

Current Time: Fri May 29 16:33:25 GMT 2020

Powered by FUDForum. Page generated in 0.01459 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top