Resource local means you can get a persistenceunit (factory)
Le 21 mars 2015 11:39, "davshowhan" <davshowhan...@gmail.com> a écrit :

> Persistence.xml file
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence";
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>    http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd";>
>
>    <persistence-unit name="Eclipselink_JPA"
> transaction-type="RESOURCE_LOCAL">
>
>       <class>com.jpa.beans.Employee</class>
>
>       <properties>
>          <property name="javax.persistence.jdbc.url"
> value="jdbc:hsqldb:file:E:\HQLDB_MYDB"/>
>          <property name="javax.persistence.jdbc.user" value="sa"/>
>          <property name="javax.persistence.jdbc.password"
> value="password"/>
>          <property name="javax.persistence.jdbc.driver"
> value="org.hsqldb.jdbc.JDBCDriver"/>
>          <property name="eclipselink.logging.level" value="FINE"/>
>          <property name="eclipselink.ddl-generation"
> value="create-tables"/>
>       </properties>
>
>    </persistence-unit>
> </persistence>
>
>
>
>
> In EJB:
>
> @Stateless
> public class EmployeeBean {
>
>           @PersistenceContext(unitName="Eclipselink_JPA")
>           private EntityManager entitymanager;
>
>
>           public void createEmployee(){
>               Employee employee = new Employee( );
>               employee.setEid( 1201 );
>               employee.setEname( "Gopal" );
>               employee.setSalary( 40000 );
>               employee.setDeg( "Technical Manager" );
>
>               entitymanager.persist( employee );
>               entitymanager.getTransaction( ).commit( );
>
>               entitymanager.close( );
>
>           }
> }
>
>
>
>
> Nullpointer happens on call of entitymanager.persist because entitymanager
> is null.....but thats not suppose to be right? it should be not null.
>
> Can anyone help me on this?
>
> libraries in project:
> eclipselink.jar
> eclipselink-jpa jars
> hsqldb.jar
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Nullpointer-on-use-of-EntityManager-in-app-run-in-TOMEE-tp4674140.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>

Reply via email to