I've started the migration of my repository from Spring3.0 -> Spring3.1 and one of the areas which is causing some problem is the migration to the new way of handling entityManagers. Right now I am configuring it using a simple standard approach:
This allows me to configure the Entities without specifying the persistence.xml file. However it is unclear how the orm.xml file is to be treated in this new environment as there are entity listeners configured within it:Code:<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="packagesToScan" value="foo.bar" /> <property name="dataSource" ref="dataSource" /> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="generateDdl" value="${db.generateDdl}"/> <property name="databasePlatform" value="${db.dialect}" /> <property name="showSql" value="${db.showSql}" /> </bean> </property> <property name="jpaPropertyMap"> <map> <entry key="namingStrategy" value="foo.bar.FooBarNamingStrategy"/> </map> </property> </bean>
Without the persistence.xml how does one tell spring that it needs to configure an entity listener on all of the spring beans so that they will support auditing?Code:<?xml version="1.0" encoding="UTF-8"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd" version="2.0"> <persistence-unit-metadata> <persistence-unit-defaults> <entity-listeners> <entity-listener class="org.springframework.data.jpa.domain.support.AuditingEntityListener" /> </entity-listeners> </persistence-unit-defaults> </persistence-unit-metadata> </entity-mappings>


Reply With Quote