Monday, 5 December 2011

Specifying EntityManagementFactory in xml

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
        <property name="persistenceUnitName" value=my_persistanceunit"/> 
        <property name="dataSource" ref="dataSource"/> 
        <property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml"/> 
        <property name="loadTimeWeaver"> 
            <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/> 
        </property> 
        <property name="jpaVendorAdapter"> 
            <bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">               
                <property name="showSql" value="true"/>  
                <property name="generateDdl" value="false"/> 
                <property name="database" value="ORACLE"/> 
            </bean> 
        </property> 
    </bean>

persistance.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
  <!-- <persistence xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
             version="2.0">-->
  <persistence-unit name="my_persistanceunit" transaction-type="RESOURCE_LOCAL">
    <description>my oracle db Persistence Unit</description>
    <class>com.my.MyEntityClass</class>
    <properties>
  </persistence-unit>
</persistence>

Use -javaagent:.lib/spring-instrument-3.0.4.RELEASE.jar  as commandline argument