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

Thread: declarative tx managements in non-web apps

  1. #1
    Join Date
    Sep 2004
    Posts
    7

    Default declarative tx managements in non-web apps

    Is it possible to implement declarative transaction management in non web apps - command line driven or Swing? Perhaps via some implementation of ApplicationContext interface?

    ThankYou for any idea.

  2. #2
    Join Date
    Aug 2004
    Posts
    1

    Default Re: declarative tx managements in non-web apps

    It shouldn't matter what kind of presentation layer you have, in multi-layer architecture, presenetation layer has dependency on business layer, not the other way around.
    Declarative tx managements should be applied on the business layer interface. So you should be able to change you presentation layer without affecting you business layer.
    For more detail discussion, please read Rod Johnson's books.

  3. #3
    Join Date
    Sep 2004
    Posts
    7

    Default

    Perhaps I should clarify myself: I have done declarative tx management in web application via applicationContext.xml and applicationContext-jdbc.xml, but I don't know how to do this in command line application. And all examples I saw on spring site or in book J2ee without EJB are only for web apps.

  4. #4
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    Is your question how to load a Spring application context from a console application? If so, take a look in Spring 1.1 Reference Guide section 3.2.1, which shows some of the options. As mentioned by leecoop, it makes no difference how your application contexts get loaded - Spring delivers transaction management just the same.

  5. #5
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    You probably want ClasspathXmlApplicationContext.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  6. #6
    Join Date
    Sep 2004
    Posts
    7

    Default

    Yes, I was trying to do something in this direction. Nevertheless I was out of luck: definitely I managed to get my method in transaction, but there was no effect. Despite rollback (see log bellow) there was insert in database, where there should not be. Perhaps it is not enough to work with connection after dataSorce.getConnection() (I must admit I'm not using any Spring JDBC library)!?
    ThankYou for clarification!

    log:

    sqle in save: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0407N Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=172, COLNO=3" is not allowed. SQLSTATE=23502

    Applying rules to determine whether transaction should rollback on java.lang.RuntimeException: [IBM][CLI Driver][DB2/NT] SQL0407N Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=172, COLNO=3" is not allowed. SQLSTATE=23502

    Winning rollback rule is: RollbackRule with pattern 'RuntimeException'
    Invoking rollback for transaction on method 'valorization' in class [si.triglav.min.interfaces.Valorization] due to throwable [java.lang.RuntimeException: [IBM][CLI Driver][DB2/NT] SQL0407N Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=172, COLNO=3" is not allowed. SQLSTATE=23502
    ]
    Triggering beforeCompletion synchronization
    Initiating transaction rollback
    Rolling back JDBC transaction on connection [
    DB2Connection
    {
    connectionHandle = 1
    SPConnected = false
    source = nzrazvoj
    user = testziv
    conArgs =
    closed = false
    describeCached = false
    describeParam = true
    isReadOnly = false
    autoClose = false
    LONGDATA compat = false
    }
    ]
    Triggering afterCompletion synchronization
    Clearing transaction synchronization
    Removed value [org.springframework.jdbc.datasource.ConnectionHold er@c4fe76] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource@23e5d1] from thread [main]
    Closing JDBC connection [
    DB2Connection
    {
    connectionHandle = 1
    SPConnected = false
    source = nzrazvoj
    user = testziv
    conArgs =
    closed = false
    describeCached = false
    describeParam = true
    isReadOnly = false
    autoClose = false

    LONGDATA compat = false
    }
    ] after transaction
    java.lang.RuntimeException: [IBM][CLI Driver][DB2/NT] SQL0407N Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=172, COLNO=3" is not allowed. SQLSTATE=23502

    at si.triglav.min.services.JdbcService.save(Unknown Source)
    at si.triglav.batch.PrevrednotenjeNZZ.valorization(Un known Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.springframework.aop.framework.AopProxyUtils.in vokeJoinpointUsingReflection(AopProxyUtils.java:61 )
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:149)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :116)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:56)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :138)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:152)
    at $Proxy0.valorization(Unknown Source)
    at si.triglav.common.SpringInTriglav.testSpring(Unkno wn Source)
    at si.triglav.common.SpringInTriglav.main(Unknown Source)
    Exception in thread "main"




    applicationContext:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>

    <!-- ========================= GENERAL DEFINITIONS ========================= -->

    <!-- Configurer that replaces ${...} placeholders with values from a properties file -->
    <!-- (in this case, JDBC-related settings for the dataSource definition below) -->
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="location"><value>resources/jdbc.properties</value></property>
    </bean>

    <!-- Message source for this context, loaded from localized "messages_xx" files
    <bean id="messageSource" class="org.springframework.context.support.Resourc eBundleMessageSource">
    <property name="basename"><value>messages</value></property>
    </bean>
    -->


    <!-- ========================= RESOURCE DEFINITIONS ========================= -->

    <!-- Local HSQL DataSource that works in any environment -->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName"><value>${jdbc.driverClassNa me}</value></property>
    <property name="url"><value>${jdbc.url}</value></property>
    <property name="username"><value>${jdbc.username}</value></property>
    <property name="password"><value>${jdbc.password}</value></property>
    </bean>


    <!-- Transaction manager for a single JDBC DataSource (alternative to JTA) -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource"><ref local="dataSource"/></property>
    </bean>

    <!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->
    <!--
    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTran sactionManager"/>
    -->


    <!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->



    <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean"
    abstract="true">
    <property name="transactionManager"><ref bean="transactionManager"/></property>
    <property name="transactionAttributes">
    <props>
    <!-- <prop key="insert*">PROPAGATION_REQUIRED</prop>-->
    <!-- <prop key="update*">PROPAGATION_REQUIRED</prop>-->
    <prop key="valor*">PROPAGATION_REQUIRED, -RuntimeException</prop>
    </props>
    </property>
    </bean>


    <bean id="valorization" parent="baseTransactionProxy">
    <property name="target">
    <bean class="si.triglav.batch.PrevrednotenjeNZZ">
    <property name="dataSource"><ref local="dataSource" /></property>
    </bean>
    </property>
    </bean>


    </beans>

  7. #7
    Join Date
    Sep 2004
    Posts
    1

    Default Re: declarative tx managements in non-web apps

    Hi,

    I'm creating a sample application using Spring configuration feature for Transaction management as well as for Database interaction. I'm using Hibernate for that purpose. I'm facing following error while getting the FileSystemXmlApplicationContext object. I've defined applicationContext-hibernate.xml file and passing that to FileSystemXmlApplicationContext class's constructor. When i run the application i get the following error:

    [9/14/04 17:10:14:171 IST] 17961796 DriverManager I org.springframework.jdbc.datasource.DriverManagerD ataSource Loaded JDBC driver: oracle.jdbc.driver.OracleDriver
    [9/14/04 17:10:14:187 IST] 17961796 DefaultListab I org.springframework.beans.factory.support.DefaultL istableBeanFactory Creating shared instance of singleton bean 'sessionFactory'
    [9/14/04 17:10:14:250 IST] 17961796 Environment I net.sf.hibernate.cfg.Environment Hibernate 2.1.4
    [9/14/04 17:10:14:250 IST] 17961796 Environment I net.sf.hibernate.cfg.Environment hibernate.properties not found
    [9/14/04 17:10:14:265 IST] 17961796 Environment I net.sf.hibernate.cfg.Environment using CGLIB reflection optimizer
    [9/14/04 17:10:14:734 IST] 17961796 Configuration E net.sf.hibernate.cfg.Configuration Could not configure datastore from input stream
    [9/14/04 17:10:14:984 IST] 17961796 Configuration E net.sf.hibernate.cfg.Configuration TRAS0014I: The following exception was logged org.dom4j.DocumentException: www.springframework.org Nested exception: www.springframework.org
    at java.lang.Throwable.<init>(Throwable.java)
    at java.lang.Throwable.<init>(Throwable.java:73)
    at org.dom4j.DocumentException.<init>(DocumentExcepti on.java:41)
    at org.dom4j.io.SAXReader.read(SAXReader.java:358)
    at net.sf.hibernate.cfg.Configuration.addInputStream( Configuration.java:283)
    at org.springframework.orm.hibernate.LocalSessionFact oryBean.afterPropertiesSet(LocalSessionFactoryBean .java:322)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:948)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:284)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:204)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:136)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:203)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:279)
    at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationC ontext.java:83)
    at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationC ontext.java:68)
    at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationC ontext.java)
    at com.fmr.xtrac.utils.AppContext.getAppContext(AppCo ntext.java:31)
    at com.fmr.xtrac.service.EmployeeService.getFrameWork (EmployeeService.java:30)
    at com.fmr.xtrac.service.EmployeeService.createOrUpda te(EmployeeService.java)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:41)
    at java.lang.reflect.Method.invoke(Method.java:386)
    at com.ibm.ws.webservices.engine.providers.java.RPCPr ovider.invokeMethod(RPCProvider.java:404)
    at com.ibm.ws.webservices.engine.providers.java.RPCPr ovider.processRequestResponse(RPCProvider.java:296 )
    at com.ibm.ws.webservices.engine.providers.java.RPCPr ovider.processMessage(RPCProvider.java:262)
    at com.ibm.ws.webservices.engine.providers.java.JavaP rovider.invoke(JavaProvider.java:289)
    at com.ibm.ws.webservices.engine.PivotHandlerWrapper. invoke(PivotHandlerWrapper.java:212)
    at com.ibm.ws.webservices.engine.handlers.WrappedHand ler.invoke(WrappedHandler.java:61)
    at com.ibm.ws.webservices.engine.PivotHandlerWrapper. invoke(PivotHandlerWrapper.java:212)
    at com.ibm.ws.webservices.engine.PivotHandlerWrapper. invoke(PivotHandlerWrapper.java:212)
    at com.ibm.ws.webservices.engine.WebServicesEngine.in voke(WebServicesEngine.java:253)
    at com.ibm.ws.webservices.engine.transport.http.WebSe rvicesServlet.doPost(WebServicesServlet.java:840)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)
    at com.ibm.ws.webservices.engine.transport.http.WebSe rvicesServletBase.service(WebServicesServletBase.j ava:341)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
    at com.ibm.ws.webcontainer.servlet.StrictServletInsta nce.doService(StrictServletInstance.java:110)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleSer vlet._service(StrictLifecycleServlet.java:174)
    at com.ibm.ws.webcontainer.servlet.IdleServletState.s ervice(StrictLifecycleServlet.java:313)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleSer vlet.service(StrictLifecycleServlet.java:116)
    at com.ibm.ws.webcontainer.servlet.ServletInstance.se rvice(ServletInstance.java:283)
    at com.ibm.ws.webcontainer.servlet.ValidServletRefere nceState.dispatch(ValidServletReferenceState.java: 42)
    at com.ibm.ws.webcontainer.servlet.ServletInstanceRef erence.dispatch(ServletInstanceReference.java:40)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.handleWebAppDispatch(WebAppRequestDispatcher. java:974)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.dispatch(WebAppRequestDispatcher.java:555)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.forward(WebAppRequestDispatcher.java:200)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForwar d(WebAppInvoker.java:119)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleIn vocationHook(WebAppInvoker.java:276)
    at com.ibm.ws.webcontainer.cache.invocation.CachedInv ocation.handleInvocation(CachedInvocation.java:71)
    at com.ibm.ws.webcontainer.srp.ServletRequestProcesso r.dispatchByURI(ServletRequestProcessor.java:182)
    at com.ibm.ws.webcontainer.oselistener.OSEListenerDis patcher.service(OSEListener.java:334)
    at com.ibm.ws.webcontainer.http.HttpConnection.handle Request(HttpConnection.java:56)
    at com.ibm.ws.http.HttpConnection.readAndHandleReques t(HttpConnection.java:618)
    at com.ibm.ws.http.HttpConnection.run(HttpConnection. java:439)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.j ava)
    Nested exception:
    java.net.UnknownHostException: www.springframework.org
    at java.lang.Throwable.<init>(Throwable.java)
    at java.lang.Throwable.<init>(Throwable.java:73)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:176)
    at java.net.Socket.connect(Socket.java:459)
    at java.net.Socket.connect(Socket.java:409)
    at sun.net.NetworkClient.doConnect(NetworkClient.java :157)
    at sun.net.www.http.HttpClient.openServer(HttpClient. java:414)
    at sun.net.www.http.HttpClient.openServer(HttpClient. java:628)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java :331)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java :292)
    at sun.net.www.http.HttpClient.New(HttpClient.java:36 4)
    at sun.net.www.http.HttpClient.New(HttpClient.java:34 5)
    at sun.net.www.http.HttpClient.New(HttpClient.java:34 0)
    at sun.net.www.protocol.http.HttpURLConnection.plainC onnect(HttpURLConnection.java:506)
    at sun.net.www.protocol.http.HttpURLConnection.connec t(HttpURLConnection.java:497)
    at sun.net.www.protocol.http.HttpURLConnection.getInp utStream(HttpURLConnection.java:599)
    at java.net.URL.openStream(URL.java:985)
    at org.apache.xerces.impl.XMLEntityManager.setupCurre ntEntity(Unknown Source)
    at org.apache.xerces.impl.XMLEntityManager.startEntit y(Unknown Source)
    at org.apache.xerces.impl.XMLEntityManager.startDTDEn tity(Unknown Source)
    at org.apache.xerces.impl.XMLDTDScannerImpl.setInputS ource(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDD ispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
    at org.apache.xerces.parsers.DTDConfiguration.parse(U nknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse( Unknown Source)
    at org.dom4j.io.SAXReader.read(SAXReader.java:339)
    at net.sf.hibernate.cfg.Configuration.addInputStream( Configuration.java:283)
    at org.springframework.orm.hibernate.LocalSessionFact oryBean.afterPropertiesSet(LocalSessionFactoryBean .java:322)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:948)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:284)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:204)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:136)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:203)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:279)
    at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationC ontext.java:83)
    at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationC ontext.java:68)
    at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationC ontext.java)
    at com.fmr.xtrac.utils.AppContext.getAppContext(AppCo ntext.java:31)
    at com.fmr.xtrac.service.EmployeeService.getFrameWork (EmployeeService.java:30)
    at com.fmr.xtrac.service.EmployeeService.createOrUpda te(EmployeeService.java)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:41)
    at java.lang.reflect.Method.invoke(Method.java:386)
    at com.ibm.ws.webservices.engine.providers.java.RPCPr ovider.invokeMethod(RPCProvider.java:404)
    at com.ibm.ws.webservices.engine.providers.java.RPCPr ovider.processRequestResponse(RPCProvider.java:296 )
    at com.ibm.ws.webservices.engine.providers.java.RPCPr ovider.processMessage(RPCProvider.java:262)
    at com.ibm.ws.webservices.engine.providers.java.JavaP rovider.invoke(JavaProvider.java:289)
    at com.ibm.ws.webservices.engine.PivotHandlerWrapper. invoke(PivotHandlerWrapper.java:212)
    at com.ibm.ws.webservices.engine.handlers.WrappedHand ler.invoke(WrappedHandler.java:61)
    at com.ibm.ws.webservices.engine.PivotHandlerWrapper. invoke(PivotHandlerWrapper.java:212)
    at com.ibm.ws.webservices.engine.PivotHandlerWrapper. invoke(PivotHandlerWrapper.java:212)
    at com.ibm.ws.webservices.engine.WebServicesEngine.in voke(WebServicesEngine.java:253)
    at com.ibm.ws.webservices.engine.transport.http.WebSe rvicesServlet.doPost(WebServicesServlet.java:840)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)
    at com.ibm.ws.webservices.engine.transport.http.WebSe rvicesServletBase.service(WebServicesServletBase.j ava:341)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
    at com.ibm.ws.webcontainer.servlet.StrictServletInsta nce.doService(StrictServletInstance.java:110)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleSer vlet._service(StrictLifecycleServlet.java:174)
    at com.ibm.ws.webcontainer.servlet.IdleServletState.s ervice(StrictLifecycleServlet.java:313)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleSer vlet.service(StrictLifecycleServlet.java:116)
    at com.ibm.ws.webcontainer.servlet.ServletInstance.se rvice(ServletInstance.java:283)
    at com.ibm.ws.webcontainer.servlet.ValidServletRefere nceState.dispatch(ValidServletReferenceState.java: 42)
    at com.ibm.ws.webcontainer.servlet.ServletInstanceRef erence.dispatch(ServletInstanceReference.java:40)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.handleWebAppDispatch(WebAppRequestDispatcher. java:974)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.dispatch(WebAppRequestDispatcher.java:555)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispat cher.forward(WebAppRequestDispatcher.java:200)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForwar d(WebAppInvoker.java:119)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleIn vocationHook(WebAppInvoker.java:276)
    at com.ibm.ws.webcontainer.cache.invocation.CachedInv ocation.handleInvocation(CachedInvocation.java:71)
    at com.ibm.ws.webcontainer.srp.ServletRequestProcesso r.dispatchByURI(ServletRequestProcessor.java:182)
    at com.ibm.ws.webcontainer.oselistener.OSEListenerDis patcher.service(OSEListener.java:334)
    at com.ibm.ws.webcontainer.http.HttpConnection.handle Request(HttpConnection.java:56)
    at com.ibm.ws.http.HttpConnection.readAndHandleReques t(HttpConnection.java:618)
    at com.ibm.ws.http.HttpConnection.run(HttpConnection. java:439)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.j ava)
    .


    can anyone help me out to resolve this issue?

    I'm using following text in the hibernate mapping file, which is being used in the applicationContext-hibernate.xml file:

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <hibernate-mapping auto-import="true">
    <class name="com.fmr.xtrac.services.types.Employee" table="X530XM1DBO.employee">
    <id name="empId" column="EID" unsaved-value="-1">
    <generator class="assigned"/>
    </id>
    <property name="name" column="Name" not-null="false" unique="false" update="true" insert="true"/>
    <property name="dept" column="departmentID" not-null="false" unique="false" update="true" insert="true"/>
    <property name="mgr" column="managerID" not-null="false" unique="false" update="true" insert="true"/>
    <property name="designation" column="Designation" not-null="false" unique="false" update="true" insert="true"/>
    </class>
    </hibernate-mapping>

    Regards,
    Arvind

  8. #8
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    Hibernate mapping file must refer to hibernate dtd not Spring dtd. you must use:
    Code:
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
        "http&#58;//hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
    HTH

    PS: Next time, please, post your question to a new thread if it does not refer to an existing one.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  9. #9
    Join Date
    Sep 2004
    Posts
    7

    Default

    I'm sorry to report I was right: declarative tx management does not work for arbitrary JDBC strategy, one must be compliant with Spring's JDBC handling, that is using its API (org.springframework.jdbc.core, org.springframework.jdbc., etc). How do I know that? Well, I took petclinic sample with spring package (version 1.1-rc2) and added method to HsqlJdbcClinic and to Clinic interface:

    public void storeOwnerPlain(Owner owner) throws DataAccessException {
    String[] sql = new String[2];
    Connection con = null;
    try {
    con = getDataSource().getConnection();
    logger.info("storeOwnerPlain 1");
    sql[0] = "insert into owners " +
    "(first_name, last_name, address, city, telephone)" +
    "values ('AngLee', 'LeeAng', '1st Street', 'Taiwan', '0000')";
    sql[1] = "insert into owners " +
    "(first_name, last_name, address, city, telephone)" +
    "values ('Ang', 'lee', 'Taiwan', '0000')";
    Statement stat = con.createStatement();
    for (int i = 0; i < sql.length; i++) {
    stat.executeUpdate(sql[i]);
    }
    } catch (SQLException e) {
    logger.info("sql.exception: " + e);
    throw new DataIntegrityViolationException(e.getMessage());
    }
    }

    Second sql has only 4 parameters instead of four and SQLException occured, nevertheless the first insert sql succeeded - there was new record in database.

    On the other hand if I sticked to Spring convention:

    public void storeOwnerPlain(Owner owner) throws DataAccessException {
    logger.info("storeOwnerPlain START");
    this.ownerInsert.insert(owner);
    this.ownerInsert.insert(null);
    }

    with

    protected void insert(Owner owner) {
    Object[] objs = null;
    if (owner != null)
    objs = new Object[] {null, owner.getFirstName(), owner.getLastName(),
    owner.getAddress(), owner.getCity(), owner.getTelephone()};
    else objs = new Object[] {null, "Abc", "Abc", "Abc"};
    super.update(objs);
    retrieveIdentity(owner);
    }

    there was rollback!!

    So am I doing perhaps something wrong or is my guess (all JDBC handling must proceed Sprin JDBC API) correct!?
    If latter, is this (non)feature documented?

    Reagards

  10. #10
    Join Date
    Aug 2004
    Posts
    1,107

    Default

    Try using TransactionAwareDataSourceProxy to wrap the datasource you are using. This proxy will intercept any "legacy" non-Spring jdbc calls and include them in the Spring managed transaction.
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

Similar Threads

  1. Programmatically rollback a declarative transaction
    By george in forum Architecture
    Replies: 10
    Last Post: Jun 15th, 2007, 01:39 PM
  2. Replies: 4
    Last Post: Jun 27th, 2005, 11:32 AM
  3. Replies: 6
    Last Post: May 17th, 2005, 11:38 PM
  4. Replies: 10
    Last Post: Nov 2nd, 2004, 09:38 AM
  5. Using spring for standalone apps
    By tv in forum Architecture
    Replies: 1
    Last Post: Sep 29th, 2004, 05:47 AM

Posting Permissions

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