-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 
Author Message
 Post subject: Using read-only transactions
PostPosted: Fri Sep 12, 2003 11:08 am 
Beginner
Beginner

Joined: Tue Sep 02, 2003 3:25 pm
Posts: 21
Location: Kingston Jamaica, West Indies
How can i set up hibernate to use readOnlyTx


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 11:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
A what?


Top
 Profile  
 
 Post subject: Using read-only transactions
PostPosted: Fri Sep 12, 2003 11:58 am 
Beginner
Beginner

Joined: Tue Sep 02, 2003 3:25 pm
Posts: 21
Location: Kingston Jamaica, West Indies
Using read-only transactions
----------------------------------

You see i am try to connect to a informix 7.3 database but
i get a error say read ony mode not supported.

When i investigated ..

The DataStoreConnection's readOnlyTx property controls whether a transaction is read-only or not.

To make JDBC connections use read-only transactions, I need to set the readOnly property of the java.sql.Connection object (returned by the java.sql.DriverManager.getConnection() to true.

does hibernate use DataStoreConnection objects ?

if so I need to set the readOnlyTx property to true before opening the connection.

Thanks
Here is the exception.

[9/12/03 10:34:26:500 GMT-05:00] 66f8db6a FreePool E J2CA0046E: Method createManagedConnctionWithMCWrapper caught an exception during creation of the ManagedConnection for resource jdbc/trn_dev, throwing ResourceAllocationException. Original exception: com.ibm.ws.exception.WsException: DSRA0080E: An exception was received by the Data Store Adapter. See original exception message: Read only mode not supported.
at com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreAdapterException.java:251)
at com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreAdapterException.java:172)
at com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreAdapterException.java:125)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.initializeConnectionProperties(WSRdbManagedConnectionImpl.java:584)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.<init>(WSRdbManagedConnectionImpl.java:359)
at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.createManagedConnection(WSManagedConnectionFactoryImpl.java:506)
at com.ibm.ejs.j2c.poolmanager.FreePool.createManagedConnectionWithMCWrapper(FreePool.java:1106)
at com.ibm.ejs.j2c.poolmanager.FreePool.createOrWaitForConnection(FreePool.java:897)
at com.ibm.ejs.j2c.poolmanager.PoolManager.reserve(PoolManager.java:1065)
at com.ibm.ejs.j2c.ConnectionManager.allocateMCWrapper(ConnectionManager.java:560)
at com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:374)
at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:205)
at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:180)
at org.springframework.orm.hibernate.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:44)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:175)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:618)
at org.springframework.orm.hibernate.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:221)
at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:189)
at org.springframework.beans.factory.support.AbstractBeanFactory.callLifecycleMethodsIfNecessary(AbstractBeanFactory.java:480)
at org.springframework.beans.factory.support.AbstractBeanFactory.createBean(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.AbstractBeanFactory.getSharedInstance(AbstractBeanFactory.java:232)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBeanInternal(AbstractBeanFactory.java:161)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:139)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:478)
at org.springframework.context.support.AbstractApplicationContext.preInstantiateSingletons(AbstractApplicationContext.java:308)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:234)
at org.springframework.web.context.support.XmlWebApplicationContext.setServletContext(XmlWebApplicationContext.java:121)
at org.springframework.web.context.ContextLoader.initContext(ContextLoader.java:55)
at org.fsl.lmis.startup.ContextLoaderServlet.init(ContextLoaderServlet.java:30)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:182)
at com.ibm.ws.runtime.WsServer.start(WsServer.java:135)
at com.ibm.ws.runtime.WsServer.main(WsServer.java:232)
at java.lang.reflect.Method.invoke(Native Method)
at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:94)
at com.ibm.etools.websphere.tools.runner.api.ServerRunnerV5$1.run(ServerRunnerV5.java:97)
---- Begin backtrace for nested exception
java.sql.SQLException: Read only mode not supported


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 12:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Well, looks awfully like this problem is completely unrelated to Hibernate to me!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 12:22 pm 
Beginner
Beginner

Joined: Tue Sep 02, 2003 3:25 pm
Posts: 21
Location: Kingston Jamaica, West Indies
Ok thanks anyway


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 12, 2004 1:57 pm 
Newbie

Joined: Mon Apr 12, 2004 1:43 pm
Posts: 5
Hi, howieh2

I am using hibernate 2.1.2 , WSAD 5.1 and informix Dynamic Server 9.40.FC3. I got the same exception like yours. Do you have the answer for it?

Here is the exception:

[4/12/04 10:28:01:179 MST] 7fc77fc7 FreePool E J2CA0046E: Method createManagedConnctionWithMCWrapper caught an exception during creation of the ManagedConnection for resource jdbc/hibernate, throwing ResourceAllocationException. Original exception: com.ibm.ws.exception.WsException: DSRA0080E: An exception was received by the Data Store Adapter. See original exception message: Read only mode not supported.
at java.lang.Throwable.<init>(Throwable.java)
at java.lang.Throwable.<init>(Throwable.java:73)
at com.ibm.ws.exception.WsException.<init>(WsException.java:106)
at com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreAdapterException.java:244)
at com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreAdapterException.java:171)
at com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreAdapterException.java:124)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.initializeConnectionProperties(WSRdbManagedConnectionImpl.java:696)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.<init>(WSRdbManagedConnectionImpl.java:453)
at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.createManagedConnection(WSManagedConnectionFactoryImpl.java:580)
at com.ibm.ejs.j2c.poolmanager.FreePool.createManagedConnectionWithMCWrapper(FreePool.java:1280)
at com.ibm.ejs.j2c.poolmanager.FreePool.createOrWaitForConnection(FreePool.java:1064)
at com.ibm.ejs.j2c.poolmanager.PoolManager.reserve(PoolManager.java:1571)
at com.ibm.ejs.j2c.ConnectionManager.allocateMCWrapper(ConnectionManager.java:622)
at com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:424)
at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:216)
at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:191)
at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:59)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1119)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:748)
at DAOFactory.init(DAOFactory.java)
at HibernatePlugIn.init(HibernatePlugIn.java:38)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:1158)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doInit(StrictServletInstance.java:82)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._init(StrictLifecycleServlet.java:147)
at com.ibm.ws.webcontainer.servlet.PreInitializedServletState.init(StrictLifecycleServlet.java:270)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.init(StrictLifecycleServlet.java:113)
at com.ibm.ws.webcontainer.servlet.ServletInstance.init(ServletInstance.java:189)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.addServlet(WebAppServletManager.java:870)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadServlet(WebAppServletManager.java:224)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadAutoLoadServlets(WebAppServletManager.java:542)
at com.ibm.ws.webcontainer.webapp.WebApp.loadServletManager(WebApp.java:1277)
at com.ibm.ws.webcontainer.webapp.WebApp.init(WebApp.java:283)
at com.ibm.ws.webcontainer.srt.WebGroup.loadWebApp(WebGroup.java:387)
at com.ibm.ws.webcontainer.srt.WebGroup.init(WebGroup.java:209)
at com.ibm.ws.webcontainer.WebContainer.addWebApplication(WebContainer.java:987)
at com.ibm.ws.runtime.component.WebContainerImpl.install(WebContainerImpl.java:136)
at com.ibm.ws.runtime.component.WebContainerImpl.start(WebContainerImpl.java:356)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:418)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:787)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:354)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:575)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:271)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:249)
at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
at com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:125)
at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:183)
at com.ibm.ws.runtime.WsServer.start(WsServer.java:128)
at com.ibm.ws.runtime.WsServer.main(WsServer.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
at java.lang.reflect.Method.invoke(Method.java:386)
at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:94)
at com.ibm.etools.websphere.tools.runner.api.ServerRunnerV5$1.run(ServerRunnerV5.java:97)
Caused by: java.sql.SQLException: Read only mode not supported
at java.lang.Throwable.<init>(Throwable.java)
at java.lang.Throwable.<init>(Throwable.java:73)
at java.sql.SQLException.<init>(SQLException.java:52)
at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:346)
at com.informix.jdbc.IfxSqliConnect.isReadOnly(IfxSqliConnect.java:1571)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.initializeConnectionProperties(WSRdbManagedConnectionImpl.java:689)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.<init>(WSRdbManagedConnectionImpl.java:453)
at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.createManagedConnection(WSManagedConnectionFactoryImpl.java:580)
at com.ibm.ejs.j2c.poolmanager.FreePool.createManagedConnectionWithMCWrapper(FreePool.java:1280)
at com.ibm.ejs.j2c.poolmanager.FreePool.createOrWaitForConnection(FreePool.java:1064)
at com.ibm.ejs.j2c.poolmanager.PoolManager.reserve(PoolManager.java:1571)
at com.ibm.ejs.j2c.ConnectionManager.allocateMCWrapper(ConnectionManager.java:622)
at com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:424)
at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:216)
at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:191)
at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:59)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1119)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:748)
at DAOFactory.init(DAOFactory.java)
at HibernatePlugIn.init(HibernatePlugIn.java:38)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:1158)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doInit(StrictServletInstance.java:82)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._init(StrictLifecycleServlet.java:147)
at com.ibm.ws.webcontainer.servlet.PreInitializedServletState.init(StrictLifecycleServlet.java:270)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.init(StrictLifecycleServlet.java:113)
at com.ibm.ws.webcontainer.servlet.ServletInstance.init(ServletInstance.java:189)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.addServlet(WebAppServletManager.java:870)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadServlet(WebAppServletManager.java:224)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadAutoLoadServlets(WebAppServletManager.java:542)
at com.ibm.ws.webcontainer.webapp.WebApp.loadServletManager(WebApp.java:1277)
at com.ibm.ws.webcontainer.webapp.WebApp.init(WebApp.java:283)
at com.ibm.ws.webcontainer.srt.WebGroup.loadWebApp(WebGroup.java:387)
at com.ibm.ws.webcontainer.srt.WebGroup.init(WebGroup.java:209)
at com.ibm.ws.webcontainer.WebContainer.addWebApplication(WebContainer.java:987)
at com.ibm.ws.runtime.component.WebContainerImpl.install(WebContainerImpl.java:136)
at com.ibm.ws.runtime.component.WebContainerImpl.start(WebContainerImpl.java:356)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:418)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:787)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:354)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:575)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:271)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:249)
at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
at com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:125)
at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:183)
at com.ibm.ws.runtime.WsServer.start(WsServer.java:128)
at com.ibm.ws.runtime.WsServer.main(WsServer.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
at java.lang.reflect.Method.invoke(Method.java:386)
at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:94)
at com.ibm.etools.websphere.tools.runner.api.ServerRunnerV5$1.run(ServerRunnerV5.java:97)


Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 12, 2004 2:56 pm 
Regular
Regular

Joined: Wed Mar 03, 2004 9:38 am
Posts: 70
I don't use Informix, but I have successfully used read only transactions with hibernate. To use them, you do something like:

Code:
Session session = ... // Hibernate session

session.connection().setReadOnly(true);

session.setFlushMode(FlushMode.NEVER);

// Your read-only tx here

session.connection().setReadOnly(false);

session.close();


Of course, if your JDBC driver/database doesn't support read only transactions, you're out of luck.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 13, 2004 2:49 am 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
joib,

that's exactly what Spring's "read-only transaction" concept boils down to when using HibernateTransactionManager: The Connection gets turned to read-only, the Session to FlushMode.NEVER. The former will happen within a try-catch block, logging a warning when the driver says "not supported", but still proceeding. Of course, you can remove the "readOnly" markers from your transaction attributes to get rid of those warnings.

Juergen


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 13, 2004 4:23 am 
Regular
Regular

Joined: Wed Mar 03, 2004 9:38 am
Posts: 70
Yes, in fact I'm using Spring declarative transactions and HibernateTransactionManager, including the use of the "readOnly" attribute where appropriate. ;-)

The code I showed above is just a "bare-bones" example about how it is done, which I understood one of the previous posters was asking about.

OTOH, looking at the stack traces, it looks like the problem is somewhat opposite. Not that I have ever used Websphere, but it looks like Websphere tries to set the connection to read-only, but Informix doesn't seem to support that.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 13, 2004 11:06 am 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
joib wrote:
Yes, in fact I'm using Spring declarative transactions and HibernateTransactionManager, including the use of the "readOnly" attribute where appropriate. ;-)


;-)

joib wrote:
OTOH, looking at the stack traces, it looks like the problem is somewhat opposite. Not that I have ever used Websphere, but it looks like Websphere tries to set the connection to read-only, but Informix doesn't seem to support that.


Indeed, it seems that WebSphere's connection pool tries to set the Connection to read-only after creating it. That behavior should be configurable somewhere in WebSphere.

On the other hand, the Informix driver isn't really well-behaved either: AFAIK, a JDBC driver should silently ignore the read-only hint if it doesn't support optimized read-only access.

Juergen


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 13, 2004 7:16 pm 
Newbie

Joined: Mon Apr 12, 2004 1:43 pm
Posts: 5
Thanks for the reply. My problem is fixed. I get the lasted informix driver and it worked now.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.