I want to inject entity manager , but when i try to use em, getting null em. Here is the codes :
SystemParameterDAOLocalInterFace.java:
---------------------------------------------------
...
@Local
public interface SystemParameterDAOLocalInterFace {
public SystemParameter getSystemParameters() ;
}
***
SystemParameterDAO.java :
--------------------------------------------------------------
@Stateful
public class SystemParameterDAO implements SystemParameterDAOLocalInterFace{
@PersistenceContext(unitName="unit1") // Already defined in persistence.xml
EntityManager em;
.........
public SystemParameter getSystemParameters() {
SystemParameter systemParameter = null;
query = em.createQuery("select sp FROM SystemParameter sp");
systemParameter = (SystemParameter)query.getSingleResult();
.....
}
-------------------------------------------------------------
any idea? Thanks ...
|