Package com.drighetto.fdr.persistence.dao

Source Code of com.drighetto.fdr.persistence.dao.FileDaoJPAImpl

package com.drighetto.fdr.persistence.dao;

import javax.persistence.EntityManager;

import com.drighetto.fdr.persistence.model.FileInformations;
import com.drighetto.fdr.transversal.FDRException;

/**
* JPA Impl. of the file DAO
*
* @author Dominique Righetto (dominique.righetto@gmail.com)
*
*/
public class FileDaoJPAImpl implements FileDao {

  /**
   * {@inheritDoc}
   *
   * @see com.drighetto.fdr.persistence.dao.FileDao#save(com.drighetto.fdr.persistence.model.FileInformations)
   */
  public void save(FileInformations informations) throws FDRException {
    EntityManager em = null;
    try {
      // Get a EntityManager instance
      em = EntityManagerFactorySingleton.getInstance().createEntityManager();
      // Persist the file informations
      em.persist(informations);
    } catch (Exception e) {
      throw new FDRException(e);
    } finally {
      // Release the EntityManager
      if (em != null) {
        em.close();
      }
    }
  }

}
TOP

Related Classes of com.drighetto.fdr.persistence.dao.FileDaoJPAImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.