Announcement Announcement Module
Collapse
No announcement yet.
An problem encount when I use Hibernate entity manager Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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

    Comment


    • #3
      Thank you very much.It does works

      Comment

      Working...
      X