Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Spring JMS and Hibernate I can't get to work together

  1. #1
    Join Date
    Sep 2009
    Posts
    28

    Default Spring JMS and Hibernate I can't get to work together

    I have been working on this the whole week and I haven't been able to get this working. My issue is that I have a JMS application that uses Spring JMS to pull the messages from the queue, I build a domain object based on the message, pass it off to data-services to use Hibernate to add a record to a data base. First I'll say that the data-services module is full of unit tests and they are all successful and I am able to add a record to the table in the db. The problem is when I run the project as a whole. I pull the message from the queue, validate the information, create the domain object, pass it on to data-services, and it writes to the table and commits(according to the logs) and all looks fine, no errors, no warnings, nothing. But the record doesn't show up in the db. It looks like the transaction is not committing, but I have no idea how that can be. The logs say that it committed. I validated that the domain object is identical to the domain object created in my unit test in data-services. So the exact same object as from the unit test is being passed into data services but the unit test puts a record in the db and full app with the JMS module doesn't work.

    Any help would be GREATLY appreciated.

    The program is setup with 3 modules, "core", "data-services", and "messaging" all under a parent pom in Maven

    Here are my application contexts:
    applicationContext.xml(from core)
    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:tx="http://www.springframework.org/schema/tx"
           xsi:schemaLocation="http://www.springframework.org/schema/beans 
                               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                               http://www.springframework.org/schema/tx 
    	   				       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    
    	<!-- 
    		This is how the ${} values throughout the application contexts are able to be populated by the filter files
    	 -->
    	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="locations">
    			<list>
    				<value>classpath:database.properties</value>
    				<value>classpath:messaging.properties</value>
    			</list>
    		</property>
    	</bean>  
    
    	<import resource="classpath:applicationContext-datasource.xml"/>
    	<import resource="classpath:applicationContext-JMS.xml"/>
    </beans>
    applicationContext-datasource.xml(from data-services)
    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:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
        					http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        					http://www.springframework.org/schema/tx 
    	   				    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    	   				    
       	<tx:annotation-driven/>  
    
        <!-- Hibernate/JPA Oracle Datasource configuration ==========================================--> 
    	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="${hibernate.connection.driver_class}"/>
            <property name="url" value="${hibernate.connection.url}"/>       
            <property name="username" value="${hibernate.connection.username}"/>
            <property name="password" value="${hibernate.connection.password}" />
        </bean>
        
        <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    		<property name="dataSource" ref="secureDataSource"/>
    		<!-- <property name="dataSource" ref="dataSource"/> -->
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">${hibernate.connection.dialect}</prop>
    			</props>
    		</property>
    		<property name="packagesToScan">
    			<list>
    				<value>com/<removed>/ground/swak/domain</value>
    			</list>
    		</property>
    	</bean>
    	
        <import resource="classpath:applicationContext-hibernate.xml" />
    </beans>
    applicationContext-hibernate.xml(from data-services)
    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:tx="http://www.springframework.org/schema/tx"
    	   xsi:schemaLocation="http://www.springframework.org/schema/beans 
    	                       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    	                       http://www.springframework.org/schema/tx 
    	   				       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    	
    	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory" ref="sessionFactory"/>
    	</bean>
    			
    	<import resource="classpath:applicationContext-data-services.xml" />
    </beans>
    applicationContext-data-services.xml(from data-services)
    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:tx="http://www.springframework.org/schema/tx"
           xsi:schemaLocation="http://www.springframework.org/schema/beans 
                               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                               http://www.springframework.org/schema/tx 
    	   				       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    
    	<!-- 
    		DAOs
    	 -->
    	<bean id="scanDetailDao" class="com.<removed>.ground.swak.dao.hibernate.BaseDaoHibernateImpl">
        	<constructor-arg value="com.<removed>.ground.swak.domain.ScanDetail"/>
        	<constructor-arg ref="sessionFactory"/>
        </bean>
        
        
        <!-- 
        	Services
         -->
         <bean id="scanDetailService" class="com.<removed>.ground.swak.service.impl.ScanDetailServiceImpl">
         	<constructor-arg ref="scanDetailDao"/>
         </bean>
         
    	<import resource="classpath:applicationContext-password-cipher.xml"/>
    </beans>
    applicationContext-password-cipher.xml(from data-services)
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> 
    <beans>
        
    	<!-- AOP Security -->
    	<bean id="secureDataSource" class="org.springframework.aop.framework.ProxyFactoryBean">
    		<property name="proxyInterfaces" value="javax.sql.DataSource" />
    		<property name="target" ref="dataSource" />
    		<property name="interceptorNames">
    			<list>
    				<value>securityMixin</value>
    			</list>
    		</property>
    	</bean>
    	
    	<bean id="securityMixin" class="com.<removed>.ground.security.server.util.SecurityDataSourceInterceptor">
    		<property name="securityModule" ref="securityModuleBean" />
    		<property name="securityGroup" value="${hibernate.connection.username}"  />
    		<property name="securityContext" value="pkg" />
    	</bean> 
    	
    	<!-- Security Module --> 
    	<bean id="securityModuleBean" class="com.<removed>.ground.security.common.util.FxgPasswordCipherFileImpl">
    		<property name="location" value="${password.cipher.file.location}" />
    	</bean>
    
    </beans>
    applicationContext-JMS.xml(from messaging)
    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:tx="http://www.springframework.org/schema/tx"
    	   xsi:schemaLocation="http://www.springframework.org/schema/beans 
                               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                               http://www.springframework.org/schema/tx 
    		   				   http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    	
    	<!-- Tibco Setup --> 
    	<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
    		<property name="environment">
    			<props>
    				<prop key="java.naming.factory.initial">${spring.jndi.initial.context.factory}</prop>
    				<prop key="java.naming.provider.url">${spring.jndi.provider.url}</prop>
    			</props>
    		</property>
    	</bean>	
    	<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiTemplate" ref="jndiTemplate" />
    		<property name="jndiName" value="${tibco.connection.factory}" />
    		<property name="proxyInterface" value="javax.jms.ConnectionFactory" />
    	</bean> 
    	<bean id="userCredentialsConnectionFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
    		<property name="targetConnectionFactory" ref="connectionFactory" />			
    		<property name="username" value="${spring.jndi.user}" />
    		<property name="password" value="${spring.jndi.password}" />
    	</bean>
    	<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    		<property name="connectionFactory" ref="userCredentialsConnectionFactory"/>
    		<property name="concurrentConsumers" value="${spring.jms.message.listener.container.consumers}"/>
    		<property name="destinationName" value="${spring.jms.message.listener.container.destination}"/>
    		<property name="messageListener" ref="messageListener"/>
    	</bean>
    	
    	<bean id="messageListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
    		<constructor-arg ref="nextGenSwakMDP"/>
    		<property name="messageConverter"><null/></property>
    	</bean>
    	
    	<bean id="nextGenSwakMDP" class="com.<removed>.ground.swak.messaging.NextGenSwakMDP">
    		<constructor-arg ref="scanDetailService"/>
    	</bean>
    </beans>

  2. #2
    Join Date
    Sep 2009
    Posts
    28

    Default

    Log from the point I get a message to when it's written to the db:
    Code:
    [NextGenSwak] - 2012-05-17 08:36:47,977 - DEBUG [jmsContainer-1] DefaultListableBeanFactory.doGetBean(242) | Returning cached instance of singleton bean 'org.springframework.transaction.interceptor.TransactionInterceptor#0'
    [NextGenSwak] - 2012-05-17 08:36:47,977 - DEBUG [jmsContainer-1] DefaultListableBeanFactory.doGetBean(242) | Returning cached instance of singleton bean 'transactionManager'
    [NextGenSwak] - 2012-05-17 08:36:47,977 - DEBUG [jmsContainer-1] HibernateTransactionManager.getTransaction(365) | Creating new transaction with name [com.<removed>.ground.swak.dao.BaseDao.insert]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
    [NextGenSwak] - 2012-05-17 08:36:48,070 - DEBUG [jmsContainer-1] HibernateTransactionManager.doBegin(493) | Opened new Session [org.hibernate.impl.SessionImpl@53d3cf] for Hibernate transaction
    [NextGenSwak] - 2012-05-17 08:36:48,070 - DEBUG [jmsContainer-1] HibernateTransactionManager.doBegin(504) | Preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@53d3cf]
    Thu May 17 08:36:48 EDT 2012 - log: decrypt called PKGAPP_USER(PKGAPP,USER)
    Thu May 17 08:36:48 EDT 2012 - log: group (PKGAPP) assigned user(pkgapp)
    Thu May 17 08:36:48 EDT 2012 - log: decrypt called PKGAPP_PASSWORD(PKGAPP,PASSWORD)
    [NextGenSwak] - 2012-05-17 08:36:48,102 - DEBUG [jmsContainer-1] DriverManagerDataSource.getConnectionFromDriver(162) | Creating new JDBC DriverManager Connection to [jdbc:oracle:thin:@ldap://oidprd.gss.ground.<removed>.com:389/DSSDEV09,cn=OracleContext,dc=ground,dc=<removed>,dc=com]
    [NextGenSwak] - 2012-05-17 08:36:48,180 - DEBUG [jmsContainer-1] HibernateTransactionManager.doBegin(569) | Exposing Hibernate transaction as JDBC transaction [oracle.jdbc.driver.T4CConnection@196de29]
    [NextGenSwak] - 2012-05-17 08:36:48,180 - TRACE [jmsContainer-1] TransactionSynchronizationManager.bindResource(183) | Bound value [org.springframework.jdbc.datasource.ConnectionHolder@1d382ab] for key [org.springframework.jdbc.datasource.DriverManagerDataSource@1947496] to thread [jmsContainer-1]
    [NextGenSwak] - 2012-05-17 08:36:48,180 - TRACE [jmsContainer-1] TransactionSynchronizationManager.bindResource(183) | Bound value [org.springframework.orm.hibernate3.SessionHolder@127e2ee] for key [org.hibernate.impl.SessionFactoryImpl@1af4309] to thread [jmsContainer-1]
    [NextGenSwak] - 2012-05-17 08:36:48,180 - TRACE [jmsContainer-1] TransactionSynchronizationManager.initSynchronization(258) | Initializing transaction synchronization
    [NextGenSwak] - 2012-05-17 08:36:48,180 - TRACE [jmsContainer-1] TransactionInterceptor.prepareTransactionInfo(344) | Getting transaction for [com.<removed>.ground.swak.dao.BaseDao.insert]
    [NextGenSwak] - 2012-05-17 08:36:48,180 - TRACE [jmsContainer-1] TransactionSynchronizationManager.getResource(139) | Retrieved value [org.springframework.orm.hibernate3.SessionHolder@127e2ee] for key [org.hibernate.impl.SessionFactoryImpl@1af4309] bound to thread [jmsContainer-1]
    [NextGenSwak] - 2012-05-17 08:36:48,289 - TRACE [jmsContainer-1] TransactionSynchronizationManager.getResource(139) | Retrieved value [org.springframework.orm.hibernate3.SessionHolder@127e2ee] for key [org.hibernate.impl.SessionFactoryImpl@1af4309] bound to thread [jmsContainer-1]
    [NextGenSwak] - 2012-05-17 08:36:48,305 - TRACE [jmsContainer-1] TransactionInterceptor.commitTransactionAfterReturning(373) | Completing transaction for [com.<removed>.ground.swak.dao.BaseDao.insert]
    [NextGenSwak] - 2012-05-17 08:36:48,305 - TRACE [jmsContainer-1] HibernateTransactionManager.triggerBeforeCommit(925) | Triggering beforeCommit synchronization
    [NextGenSwak] - 2012-05-17 08:36:48,305 - TRACE [jmsContainer-1] HibernateTransactionManager.triggerBeforeCompletion(938) | Triggering beforeCompletion synchronization
    [NextGenSwak] - 2012-05-17 08:36:48,305 - DEBUG [jmsContainer-1] HibernateTransactionManager.processCommit(752) | Initiating transaction commit
    [NextGenSwak] - 2012-05-17 08:36:48,305 - DEBUG [jmsContainer-1] HibernateTransactionManager.doCommit(652) | Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@53d3cf]
    [NextGenSwak] - 2012-05-17 08:36:48,320 - TRACE [jmsContainer-1] HibernateTransactionManager.triggerAfterCommit(951) | Triggering afterCommit synchronization
    [NextGenSwak] - 2012-05-17 08:36:48,320 - TRACE [jmsContainer-1] HibernateTransactionManager.triggerAfterCompletion(967) | Triggering afterCompletion synchronization
    [NextGenSwak] - 2012-05-17 08:36:48,320 - TRACE [jmsContainer-1] TransactionSynchronizationManager.clearSynchronization(316) | Clearing transaction synchronization
    [NextGenSwak] - 2012-05-17 08:36:48,320 - TRACE [jmsContainer-1] TransactionSynchronizationManager.doUnbindResource(229) | Removed value [org.springframework.orm.hibernate3.SessionHolder@127e2ee] for key [org.hibernate.impl.SessionFactoryImpl@1af4309] from thread [jmsContainer-1]
    [NextGenSwak] - 2012-05-17 08:36:48,320 - TRACE [jmsContainer-1] TransactionSynchronizationManager.doUnbindResource(229) | Removed value [org.springframework.jdbc.datasource.ConnectionHolder@1d382ab] for key [org.springframework.jdbc.datasource.DriverManagerDataSource@1947496] from thread [jmsContainer-1]
    [NextGenSwak] - 2012-05-17 08:36:48,336 - DEBUG [jmsContainer-1] HibernateTransactionManager.doCleanupAfterCompletion(734) | Closing Hibernate Session [org.hibernate.impl.SessionImpl@53d3cf] after transaction
    [NextGenSwak] - 2012-05-17 08:36:48,336 - DEBUG [jmsContainer-1] SessionFactoryUtils.closeSession(789) | Closing Hibernate Session

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Post some code your configuration seems fine at first sight although I wonder why you use the DriverManagerDataSource as that isn't something to use in production/live systems as you should use a real connection pool.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  4. #4
    Join Date
    Sep 2009
    Posts
    28

    Default

    The MDP:
    Code:
    public class NextGenSwakMDP {
    
    	private Logger log = Logger.getLogger(NextGenSwakMDP.class);
    	
    	/**
    	 * Spring injected Scan Detail Service to add scan detail records.
    	 */
    	private ScanDetailService scanDetailService;
    	
    	/**
    	 * Constructor 
    	 * 
    	 * @param scanDetailService
    	 */
    	public NextGenSwakMDP(ScanDetailService scanDetailService) {
    		this.scanDetailService = scanDetailService;
    	}
    	
    	/**
    	 * Catches a BytesMessage from the queue
    	 * 
    	 * @param message
    	 */
    	public void handleMessage(BytesMessage message) {
    		System.out.println("caught a byte.");
    		
    		String stringMessage = convertBytesMessageToString(message);
    		ScanDetail scanDetail = generateEpdiScanDoc(stringMessage);
    		
    		if (scanDetail != null) {
    			scanDetailService.insertScanDetail(scanDetail);
    		}
    		try {
    			message.acknowledge();
    		} catch (JMSException e) {
    			System.out.println("failed ackowledgement");
    			e.printStackTrace();
    		}
    		System.out.println("completed");
    	}
    	
    	/**
    	 * Converts a BytesMessage to a String
    	 * 
    	 * @param message
    	 * @return
    	 */
    	private String convertBytesMessageToString(BytesMessage message) {
    		try {
    			long msgLength = message.getBodyLength();
    			byte[] messageByteArray = new byte[(int) msgLength];
    			message.readBytes(messageByteArray);
    			log.debug(new String(messageByteArray));
    			
    	        return new String(messageByteArray); 
    		} catch(JMSException e) {
    			log.error("Error converting Bytes message to string.");
    			log.error(e.getMessage());
    			e.printStackTrace();
    			
    			return null;
    		}
    	}
    	
    	/**
    	 * This is validating the xml and converting it to the ScanDetil domain object in
    	 * order to insert it into the SCAN_DETAIL table on DSSPRD09
    	 * 
    	 * @param xmlString
    	 * @return
    	 */
    	private ScanDetail generateEpdiScanDoc(String xmlString) {
    		EpdiScanDocument epdiScanDoc = EpdiScanDocument.Factory.newInstance();
    		EpdiScanDocument.EpdiScan epdiScan = EpdiScanDocument.EpdiScan.Factory.newInstance();
    		
    		ScanDetail scanDetail = new ScanDetail();
    		
            // Attempt to parse the XML string that was passed in		
    		try {
    			XmlOptions parseOptions = new XmlOptions();
    			parseOptions.setLoadReplaceDocumentElement(new QName("http://swk.ground.<removed>.com/schemas/EpdiScan", "EpdiScan"));
    			epdiScanDoc = EpdiScanDocument.Factory.parse(xmlString, parseOptions);
    		} catch(XmlException e) {
    			log.error("Error occured while parsing XML", e);
    			log.error(xmlString);
    		}
    
    		if (!XmlUtils.validateXmlObject(epdiScanDoc)) {
    			log.error("XML document failed validation. Details above. Document in error: ");
    			log.error(xmlString);
    			
    			return null;
    		}
    				
    		epdiScan = epdiScanDoc.getEpdiScan();
    		ScanDetailCompositeKey compositeKey = new ScanDetailCompositeKey();
    		
    		compositeKey.setScanCreateTime(epdiScan.getScanTime().getTime());
    		compositeKey.setScanIorgNumber(epdiScan.getScanningFacility());
    		compositeKey.setTrackingId1(epdiScan.getBarcode1());
    		compositeKey.setTrackingId2(epdiScan.getBarcode2());
    		scanDetail.setCompositeKey(compositeKey);
    
    		scanDetail.setScanCreateDate(epdiScan.getScanDate().getTime());
    		scanDetail.setAdscanSortTypeCode("ST" + epdiScan.getRecordType());
    		scanDetail.setScanBarcode(epdiScan.getBarcodeScanned());
    		scanDetail.setAdscanScanTypeCode("SP" + epdiScan.getScanType());
    		scanDetail.setAdscanPackageLookupStatusCode("PL" + epdiScan.getPackageStatus());
    		scanDetail.setVehicleUnitNumber(epdiScan.getUnit());
    		scanDetail.setScanUser(epdiScan.get<removed>Id());
    		scanDetail.setNextLoadPoint(epdiScan.getNextLoadPoint());
    		scanDetail.setPackageLabelXref(calculateXref(epdiScan));
    		
    		return scanDetail;
    	}

  5. #5
    Join Date
    Sep 2009
    Posts
    28

    Default

    The Generic DAO:

    Code:
    @SuppressWarnings("unchecked")
    public class BaseDaoHibernateImpl<T, ID extends Serializable> implements BaseDao<T, ID> {
    
    	private Logger log = Logger.getLogger(BaseDaoHibernateImpl.class);
    	
    	/**
    	 * This is a Factory from hibernate that gives us a current session so that we can maintain a 
    	 * transaction if we need to to keep a db connection open. A Session is the hibernate equivilant
    	 * to JPAs EntityManager
    	 */
    	private SessionFactory sessionFactory;
    
    	/**
    	 * This is a reference to the type of object(class) that this implementation was created for. 
    	 */
    	private Class<T> classType;
    	
    	/**
    	 * Constructor 
    	 * 
    	 * @param classType this is the reference to the class that this dao is based on
    	 */
    	public BaseDaoHibernateImpl(final Class<T> classType, SessionFactory sessionFactory) {
    		this.classType = classType;
    		this.sessionFactory = sessionFactory;
    	}
    
    	/**
    	 * This will insert a record into the Domain objects table
    	 * 
    	 * @param <T> entity
    	 */
    	public boolean insert(T entity) {
    		try {
    			getCurrentSession().saveOrUpdate(entity);
    		} catch(Exception e) {
    			log.error("Error adding record to SCAN_DETAIL");
    			log.error(e);
    			return false;
    		}
    		
    		return true;
    	}
    	
    	/**
    	 * This will get the current session that the user will run his transactions in. If there is no
    	 * current session, one will be greated and returned. This class MUST be @Transactional for
    	 * this to work.
    	 * 
    	 * @return
    	 */
    	private Session getCurrentSession() {
    		return sessionFactory.getCurrentSession();
    	}
    }

  6. #6
    Join Date
    Sep 2009
    Posts
    28

    Default

    Let me know if you want anything else. The only thing I can think of is it is transaction related. But I don't see why it would be.

  7. #7
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    For starters your tx setup is wrong you should not catch the exceptions as this breaks springs tx support (it always thinks everything is fine whilst it actually isn't. Your transactions are working (at least configuration wise) as else you get an exception on getCurrentSession.

    What is your service like?
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  8. #8
    Join Date
    Sep 2009
    Posts
    28

    Default

    So you're saying in the DAO i should throw all the exceptions?

    Service is really basic.
    Code:
    public class ScanDetailServiceImpl implements ScanDetailService{
    
    	private Logger log = Logger.getLogger(ScanDetailServiceImpl.class);
    	private BaseDao<ScanDetail, ScanDetailCompositeKey> scanDetailDao;
    	
    	public ScanDetailServiceImpl(BaseDao<ScanDetail, ScanDetailCompositeKey> scanDetailDao) {
    		this.scanDetailDao = scanDetailDao;
    	}
    	
    	public boolean insertScanDetail(ScanDetail scanDetail) {
    		try {
    			scanDetailDao.insert(scanDetail);
    		} catch(Exception e) {
    			log.error("Error adding SCAN_DETAIL row");
    			log.error(e);
    			return false;
    		}
    		return true;
    	}	
    }

  9. #9
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    And the same goes for the service also. If spring doesn't see the exception it won't rollback.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  10. #10
    Join Date
    Sep 2009
    Posts
    28

    Default

    Thanks, I corrected both of those. But since there were no errors being thrown it didn't change anything. Still no commits.

Posting Permissions

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