Create a gist now

Instantly share code, notes, and snippets.

package com.arthurportas.persistence.daos;
import com.arthurportas.persistence.PersistenceEnum;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
* Created by arthurportas on 14/05/2017.
public abstract class GenericDaoImpl<T> implements GenericDao<T>{
protected EntityManager getEntityManager() {
return Persistence.createEntityManagerFactory(PersistenceEnum.PERSISTENCE_UNIT.getValue()).createEntityManager();
public T save(T entity) {
return entity;
public void delete(T entity) {
public T update(T entity) {
return getEntityManager().merge(entity);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment