Results 1 to 3 of 3

Thread: An problem encount when I use Hibernate entity manager

  1. #1
    Join Date
    Jul 2005
    Posts
    24

    Default An problem encount when I use Hibernate entity manager

    I use spring 2.0M2 and hibernate entitymanager
    my persistence.xml file
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence>
       <persistence-unit name="TestEntityManager" transaction-type="RESOURCE_LOCAL">
          <provider>org.hibernate.ejb.HibernatePersistence</provider>
          <class>com.jl.sub1.Product</class>
          <class>com.jl.sub1.ProductItem</class>
          <properties>
              <property name="hibernate.dialect" value="org.hibernate.dialect.DB2Dialect" />
              <property name="hibernate.connection.driver_class" value="com.ibm.db2.jcc.DB2Driver" />
              <property name="hibernate.connection.password" value="db2admin" />
              <property name="hibernate.connection.url" value="jdbc:db2://10.1.1.10:50000/dbjl" />
              <property name="hibernate.connection.username" value="db2admin" />
              <property name="hibernate.ejb.autodetection" value="class" />
    			</properties>
       </persistence-unit>
    </persistence>
    Spring config file
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    	<bean id="entityManagerFactory1" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    		<property name="entityManagerName" value="TestEntityManager" />
    	</bean>
    	
    	<bean id="transactionManager1" class="org.springframework.orm.jpa.JpaTransactionManager">
    		<property name="entityManagerFactory" ref="entityManagerFactory1" />
    	</bean>
    	
    	<bean id="transactionInterceptor1" class="org.springframework.transaction.interceptor.TransactionInterceptor">
    		<property name="transactionManager" ref="transactionManager1" />
    		<property name="transactionAttributeSource">
    			<bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource" />
    		</property>
    	</bean>
    
    <!-- Service -->
    	<bean id="persistenceManagerTarget1" class="com.jl.sub1.PersistenceManagerImpl">
    		<property name="entityManagerFactory" ref="entityManagerFactory1" />
    	</bean>
    	
    	<bean id="persistenceManager1" class="org.springframework.aop.framework.ProxyFactoryBean">
    		<property name="proxyInterfaces">
    			<value>com.jl.sub1.PersistenceManager</value>
    		</property>
    		<property name="interceptorNames">
    			<list>
    				<idref local="transactionInterceptor1" />
    				<idref local="persistenceManagerTarget1" />
    			</list>
    		</property>
    	</bean>
    </beans>
    my app server is Tomcat 5.5.10,but I got a java.lang.NullPointerException when my application start,here is my screen shot ,what's the problem
    Attached Images Attached Images

  2. #2
    Join Date
    Nov 2005
    Location
    Tel-Aviv,Israel
    Posts
    11

    Default

    Hi,
    There is a bug in the current Hibernate Entity Manager (3.1beta6). If the Persistence.creaeEntityManagerFactory() method doesn't get an options map it crashes (see http://opensource2.atlassian.com/pro...browse/EJB-124)

    To workaround give an empty options map:

    Code:
    <bean id="entityManagerFactory1" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    		<property name="entityManagerName" value="TestEntityManager" />
                    <property name="jpaProperties"><props></props></property>
    </bean>
    It should work,
    Eyal Lupu

  3. #3
    Join Date
    Jul 2005
    Posts
    24

    Default

    Thank you very much.It does works

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •