Results 1 to 3 of 3

Thread: Configuring EntityListener without Persistence.xml

  1. #1

    Default Configuring EntityListener without Persistence.xml

    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:

    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>
    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:
    <?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>
    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?

  2. #2
    Join Date
    Apr 2012
    Posts
    1

    Default

    I am also looking for this solution for ages now. How did it go? Did you solve it?

    Could you please submit a solution if you solved it?

  3. #3
    Join Date
    Nov 2012
    Posts
    3

    Default

    With spring 3.1 a new mappingResource property has been added. That property allow to specify the path of the orm.xml file. (see https://jira.springsource.org/browse/SPR-8440).

    Unfortunately I'm not sure this really work because I cannot get the AuditingEntityListener to work in my project (see http://forum.springsource.org/showth...EntityListener)

    Andrea

Posting Permissions

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