G
Gast2
Gast
Hallo zusammen,
ich versuche gerade ein mit Spring DM und Eclipse Link zu arbeiten. Doch mein EntityManager ist immer null.
Meine xml config is:
[XML]
<context:annotation-config />
<context:load-time-weaver weaver-class="org.eclipse.equinox.weaving.springweaver.EquinoxAspectsLoadTimeWeaver"/>
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
<context:component-scan base-package="db" annotation-config="true" />
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="url" value="jdbc:derby:kunde;create=true" />
</bean>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
[/XML]
Meine DAO:
Der Consolen log lautet:
Ich hab die ganzen El-Config wo er die Tabellen generiert mal draußen gelassen. Die EntityManagerFactory wird ja generiert und ich dachte mit der PersistenceContext Annotation wird die Factory den EntityManager injecten. Klappt leider nicht hat jemand eine Idee oder sieht ein Fehler in der config?
ich versuche gerade ein mit Spring DM und Eclipse Link zu arbeiten. Doch mein EntityManager ist immer null.
Meine xml config is:
[XML]
<context:annotation-config />
<context:load-time-weaver weaver-class="org.eclipse.equinox.weaving.springweaver.EquinoxAspectsLoadTimeWeaver"/>
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
<context:component-scan base-package="db" annotation-config="true" />
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="url" value="jdbc:derby:kunde;create=true" />
</bean>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
[/XML]
Meine DAO:
Java:
public class DAO {
@PersistenceContext
private EntityManager entityManager;
Der Consolen log lautet:
Java:
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@92668c: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,loadTimeWeaver,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,dataSource,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0,entityManagerFactory,transactionManager,tableview,dao]; root of factory hierarchy
14.09.2010 10:51:31 org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean createNativeEntityManagerFactory
INFO: Building JPA container EntityManagerFactory for persistence unit 'kunde'
[El-Config]...
transformer added; Standard ClassFileTransformer wrapping JPA transformer: org.eclipse.persistence.internal.jpa.weaving.PersistenceWeaver@40d611
14.09.2010 10:51:31 org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext publishContextAsOsgiServiceIfNecessary
Ich hab die ganzen El-Config wo er die Tabellen generiert mal draußen gelassen. Die EntityManagerFactory wird ja generiert und ich dachte mit der PersistenceContext Annotation wird die Factory den EntityManager injecten. Klappt leider nicht hat jemand eine Idee oder sieht ein Fehler in der config?