@Override
	public void persist(Vector<StockEntry> data) throws Exception {
        Date minDate = getMinDate(data);
        Date maxDate = getMaxDate(data);

	    EntityManager em = null;
	    try {
	    	em = EMF.get().createEntityManager();
		    em.getTransaction().begin();
	    	Query query = em.createQuery("delete from StockEntry as e where e.date >= :minDate and e.date <= :maxDate");
	    	query.setParameter("minDate", minDate);
	    	query.setParameter("maxDate", maxDate);
	    	query.executeUpdate();

	    	MasterEntity master = new MasterEntity();
	    	
	    	for (StockEntry entry : data) {
	    		master.addEntry(entry);
			    //em.persist(entry);
	        }
	    	em.persist(master);
	    	em.getTransaction().commit();
	    } catch (Exception e) {
	    	if (em != null && em.getTransaction().isActive()) {
		    	em.getTransaction().rollback();
	    	}
	    	throw e;
	    } finally {
	    	if (em != null) {
	    		em.close();
	    	}
	    }
	}