openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cil-Gamir <hannes.visa...@rmb.co.za>
Subject Re: Locking Exception after Persisting new entity
Date Thu, 12 Nov 2009 16:26:35 GMT

The DAO Above gets extended by this class

package za.co.rmb.rac.riskRatingEngineWeb.dao;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.OptimisticLockException;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.apache.log4j.Logger;

import za.co.rmb.rac.basicjpadao.DAO;
import za.co.rmb.rac.riskRatingEngineWeb.entities.Threshold;
import za.co.rmb.rac.riskRatingEngineWeb.entities.Variable;
import za.co.rmb.rac.riskRatingEngineWeb.entities.Regulator;

public class RiskRatingDAO extends DAO {

    private static RiskRatingDAO instance;
    private static Logger log = Logger.getLogger(RiskRatingDAO.class);
    private EntityManager entityManager;
    private Logger logger = Logger.getLogger(this.getClass().getName());

    private RiskRatingDAO() {
    }

    public static RiskRatingDAO getInstance() {
        if (instance == null) {
            instance = new RiskRatingDAO();
        }
        return instance;
    }

    @Override
    public EntityManager getEntityManager() {
        if (entityManager == null) {
            log.info("creating entitymanager");
            entityManager =
Persistence.createEntityManagerFactory("risk-rating-data-engine").createEntityManager();
        }
        return entityManager;
    }

    @Override
    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;
    }   
-- 
View this message in context: http://n2.nabble.com/Re-SOLVED-Re-Locking-Exception-after-Persisting-new-entity-tp3992651p3993922.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message