Hello
I`ve been already searching this forum and also studying reference manual, but I still don`t know how to solve this problem.
I`m using Spirng 2.5.6, TopLink, database IBM DB2 and using JPA as persistence manager. This all runs on Tomcat 6. I haven`t add any configuration classes there, bcs I have a mess in my head what class belogns where. I`ve been sitting all day long on this, so please help if you can
My dispatcher-servlet.xml:
And ContactDAO:Code:<?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:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <bean id="controllermap" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="/browse.ucm">browseController</prop> <prop key="/add.ucm">addController</prop> </props> </property> </bean> <context:component-scan base-package="net.chrenko.marek.pa165.ucm" /> <bean id="browseController" class="net.chrenko.marek.pa165.ucm.BrowseController"> <property name="contactService"> <ref bean="contactService" /> </property> </bean> <bean id="addController" class="net.chrenko.marek.pa165.ucm.AddController"> <property name="contactService"> <ref bean="contactService" /> </property> </bean> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <bean id="contactService" class="net.chrenko.marek.pa165.ucm.ContactDAO"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter"> <property name="showSql" value="true"/> <property name="generateDdl" value="true"/> <property name="databasePlatform" value="oracle.toplink.essentials.platform.database.DB2Platform"/> </bean> </property> <property name="loadTimeWeaver"> <bean class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver" /> </property> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver" /> <property name="url" value="jdbc:db2://127.0.0.1:50000/ucm"/> <property name="username" value="ADMINISTRATOR"/> <property name="password" value="passwordofcourse"/> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> <property name="dataSource" ref="dataSource"/> </bean> <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"> <property name="transactionManager" ref="transactionManager"/> <property name="transactionAttributes"> <props> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="delete*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <bean id="dbService" parent="baseTransactionProxy"> <property name="target"> <bean class="net.chrenko.marek.pa165.ucm.ContactDAO"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> </property> </bean> </beans>
When testing or reading DB, everything is OK, when trying to insert or update, an IllegalArgumentException occurres.Code:package net.chrenko.marek.pa165.ucm; import org.springframework.orm.jpa.support.JpaDaoSupport; import org.springframework.transaction.annotation.Transactional; import java.util.List; /** * Created by IntelliJ IDEA. * User: Marek Chrenko * Date: 21.11.2009 * Time: 16:59:59 * Implementation of Contact Service using interface + Java Persistence API DAO template */ public class ContactDAO extends JpaDaoSupport implements ContactService { public Contact save(Contact contact) { getJpaTemplate().persist(contact); return contact; } public Contact update(Contact contact) { return getJpaTemplate().merge(contact); } public void delete(Contact contact) { getJpaTemplate().remove(contact); } public List<Contact> findAllContacts() { return getJpaTemplate().find("select c from Contact c"); } public List<Contact> findContactName(String name) { return getJpaTemplate().find("select c from Contact c where c.name=?1",name); } public List<Contact> findContactSurname(String surname) { return getJpaTemplate().find("select c from Contact c where c.surname=?1",surname); } public List<Contact> findContactEmail(String email) { return getJpaTemplate().find("select c from Contact c where c.email=?1",email); } public List<Contact> findContactPhone(String phone) { return getJpaTemplate().find("select c from Contact c where c.phoneNumber.number=?1",phone); } }
I`ve already add baseTransactionProxy, but as I`ve already written - there is one big mess in my headPlease help, thanks in advance
![]()



Reply With Quote
