package com.simstock.services;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 * Implementation of the generic Data Access Service All CRUD (create, read,
 * update, delete) basic data access operations for any persistent object are
 * performed in this class.
 **/
public abstract class DataAccessService<T> {

	@PersistenceContext
	private EntityManager em;

	public DataAccessService() {
	}

	private Class<T> type;

	/**
	 * Default constructor
	 *
	 * @param type
	 *            entity class
	 */
	public DataAccessService(Class<T> type) {
		this.type = type;
	}

	/**
	 * Stores an instance of the entity class in the database
	 * 
	 * @param T
	 *            Object
	 * @return
	 */
	public T create(T t) {
		this.em.persist(t);
		this.em.flush();
		this.em.refresh(t);
		return t;
	}

	/**
	 * Retrieves an entity instance that was previously persisted to the
	 * database
	 * 
	 * @param T
	 *            Object
	 * @param id
	 * @return
	 */
	public T find(Object id) {
		return this.em.find(this.type, id);
	}

}
@@ -122,31 +122,9 @@
 %0A * 
-Implementation of the g
+G
 ener
@@ -149,51 +149,19 @@
 vice
- All CRUD (create, read,%0A * update, delete)
+%0A * %0A * The
  bas
@@ -215,19 +215,16 @@
 ject are
-%0A *
  perform
@@ -228,16 +228,19 @@
 ormed in
+%0A *
  this cl

update comment