users@glassfish.java.net

Re: Spring 2.0, JPA and Glassfish

From: <glassfish_at_javadesktop.org>
Date: Mon, 18 Jun 2007 09:07:15 PDT

thanks, yes the Item has the @Entity notation. Like I said, I modified code that was working to use spring (I didn't change the entity classes, just the code that gets the entityManager). I don't have an orm.xml file.
here is my persistence.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-unit name="PetCatalogPu" transaction-type="JTA">
        <jta-data-source>jdbc/PETCatalogDB</jta-data-source>
        <properties/>
    </persistence-unit>
</persistence>
Here is my applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
   
    <bean id="catalogService" class="service.CatalogDAO"/>
      
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="loadTimeWeaver">
            <bean class="org.springframework.instrument.classloading.glassfish.GlassFishLoadTimeWeaver"/>
        </property>
        <property name="jpaVendorAdapter">
            <bean
                class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter">
                <property name="showSql" value="true" />
                <property name="generateDdl" value="false" />
                <property name="databasePlatform"
                          value="oracle.toplink.essentials.platform.database.DerbyPlatform" />
            </bean>
        </property>
    </bean>
       
    <bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.apache.derby.jdbc.ClientDriver" />
        <property name="url" value="jdbc:derby://localhost:1527/pet-catalog" />
        <property name="username" value="app" />
        <property name="password" value="app" />
    </bean>
      
    <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
       
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
        <property name="dataSource" ref="dataSource"/>
    </bean>
    
    <tx:annotation-driven />
    
    <bean name="itemController" class="sessionpagination.ItemController">
        <property name="catalogService">
            <ref bean="catalogService"/>
        </property>
    </bean>
    
</beans>
[Message sent by forum member 'caroljmcdonald' (caroljmcdonald)]

http://forums.java.net/jive/thread.jspa?messageID=222725