Posted By

virgium03hotmailcom on 10/07/10


entity add Generic Hibernate

Versions (?)

Adding an entity in a generic way using Hibernate

 / Published in: Java

  1. public <T> T add(final T obj) {
  2. return get(obj.getClass(), (Long) getHibernateTemplate().save(obj));
  3. }
  4. public final <T> T get(final Class<T> clazz, final Long id) {
  5. return (T) getHibernateTemplate().get(clazz, id);
  6. }

Report this snippet  

You need to login to post a comment.