You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by CuriousMind <yo...@hotmail.com> on 2009/08/04 06:48:02 UTC
PL/SQL package level variables
Hi,
I am having 3 procedures which i want to call using IBatis framework. These
procedure are using package level variables and hence when I try to call
them, it ends up throwing error as the package variable value is not found.
Consider following scenario for more details
Package level variable = varPK
Procedure 1 sets varPK (Package level variable) to "SomeValue"
Procedure 2 tries to check value of varPK and finds that it is empty.
I know this could be resolved by writing wrapper procedure which will call
above listed procedure in sequence but I am looking for better solution. The
problem is that I am migrating existing application to Ibatis framework and
hence it is not possible to find out where such scenarios would come.
The error that I am facing is probably due to for every call to iBatis API
gets different connection object (I am using connection pool and spring
integration with ibatis.). I think this can be resolved only if current
thread will get same connection instance. Is there any way to ensure that
the current thread will always receive same connection instance?
--
View this message in context: http://www.nabble.com/PL-SQL-package-level-variables-tp24802267p24802267.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Re: PL/SQL package level variables
Posted by Nicholoz Koka Kiknadze <ki...@gmail.com>.
Honestly, I don't quite understand your config. You have
<tx:annotation-driven transaction-manager="txManager" />
So I guess you use annotations to mark transactions. In that case you all
that advice/pointcut stuff seems redundant.
Now as you do not set proxy-target-class=true dont forget that you need to
put Transactional annotations at the interface level.
On Thu, Aug 20, 2009 at 5:09 PM, CuriousMind <yo...@hotmail.com>wrote:
>
> Here is the code snippet for the transaction management
>
> <bean id="txManager"
> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
> <property name="dataSource" ref="dataSource" />
> </bean>
> <tx:annotation-driven transaction-manager="txManager" />
>
> <tx:advice id="txAdvice" transaction-manager="txManager" >
> <tx:attributes>
> <tx:method name="get*" propagation="SUPPORTS"
> read-only="true"/>
> <tx:method name="*" propagation="REQUIRED"
>
> rollback-for="java.sql.SQLException,com.framework.exception.types.BusinessException"/>
> </tx:attributes>
> </tx:advice>
>
> <aop:config>
> <aop:pointcut id="databaseOperation" expression="execution(*
> com.business.component..*(..))"/>
> <aop:advisor advice-ref="txAdvice"
> pointcut-ref="databaseOperation"/>
> </aop:config>
>
> & Here goes the code for ibatis configuration
>
>
> <bean id="sqlMapClient"
> class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
> <property name="configLocation"
> value="classpath:com/dataservice/ibatis/config/SQLMapConfig.xml"/>
> <property name="dataSource" ref="dataSource"/>
> <property name="useTransactionAwareDataSource" value="true"
> />
> <property name="transactionConfigClass">
>
>
> <value>com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig</value>
> </property>
>
> <property name="transactionConfigProperties">
> <props>
> <prop key="DefaultAutoCommit">false</prop>
> </props>
> </property>
>
> </bean>
>
>
> Nicholoz Koka Kiknadze wrote:
> >
> > Hm, but I have used package variables at Oracle 9 times (with JDBC
> though,
> > but iBatis just wraps JDBC) and it worked fine.
> >
> > May I ask how do you handle transactions, and may I look at the code
> > snippet
> > calling those procedures?
> >
> > On Tue, Aug 4, 2009 at 9:44 AM, CuriousMind
> > <yo...@hotmail.com>wrote:
> >
> >>
> >> Hi Nichol,
> >>
> >> Thanks for your response. We are already using same transaction while
> >> calling these procedures.
> >> But we are not getting expected results.
> >>
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/PL-SQL-package-level-variables-tp24802267p25061697.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>
Re: PL/SQL package level variables
Posted by CuriousMind <yo...@hotmail.com>.
Here is the code snippet for the transaction management
<bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="txManager" />
<tx:advice id="txAdvice" transaction-manager="txManager" >
<tx:attributes>
<tx:method name="get*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"
rollback-for="java.sql.SQLException,com.framework.exception.types.BusinessException"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="databaseOperation" expression="execution(*
com..business.component..*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="databaseOperation"/>
</aop:config>
& Here goes the code for ibatis configuration
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation"
value="classpath:com/dataservice/ibatis/config/SQLMapConfig.xml"/>
<property name="dataSource" ref="dataSource"/>
<property name="useTransactionAwareDataSource" value="true" />
<property name="transactionConfigClass">
<value>com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig</value>
</property>
<property name="transactionConfigProperties">
<props>
<prop key="DefaultAutoCommit">false</prop>
</props>
</property>
</bean>
Nicholoz Koka Kiknadze wrote:
>
> Hm, but I have used package variables at Oracle 9 times (with JDBC though,
> but iBatis just wraps JDBC) and it worked fine.
>
> May I ask how do you handle transactions, and may I look at the code
> snippet
> calling those procedures?
>
> On Tue, Aug 4, 2009 at 9:44 AM, CuriousMind
> <yo...@hotmail.com>wrote:
>
>>
>> Hi Nichol,
>>
>> Thanks for your response. We are already using same transaction while
>> calling these procedures.
>> But we are not getting expected results.
>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/PL-SQL-package-level-variables-tp24802267p25061697.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Re: PL/SQL package level variables
Posted by Larry Meadors <la...@gmail.com>.
You can use an anonymous pl/sql block in ibatis, too.
Larry
On Mon, Aug 3, 2009 at 11:59 PM, Nicholoz Koka
Kiknadze<ki...@gmail.com> wrote:
> Hm, but I have used package variables at Oracle 9 times (with JDBC though,
> but iBatis just wraps JDBC) and it worked fine.
>
> May I ask how do you handle transactions, and may I look at the code snippet
> calling those procedures?
>
> On Tue, Aug 4, 2009 at 9:44 AM, CuriousMind <yo...@hotmail.com>
> wrote:
>>
>> Hi Nichol,
>>
>> Thanks for your response. We are already using same transaction while
>> calling these procedures.
>> But we are not getting expected results.
>>
>>
>>
>>
>> Nicholoz Koka Kiknadze wrote:
>> >
>> > You are quite right. Your problem is that calls to those two procedures
>> > are
>> > not in a single transaction. Include them in a single transaction and
>> > proc2
>> > will see package level variables set in proc1. Note that executing those
>> > procs on a single connection object is not enough (i.e. you need
>> > transaction).
>> >
>> > hth
>> >
>> > On Tue, Aug 4, 2009 at 8:48 AM, CuriousMind
>> > <yo...@hotmail.com>wrote:
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/PL-SQL-package-level-variables-tp24802267p24802615.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Re: PL/SQL package level variables
Posted by Nicholoz Koka Kiknadze <ki...@gmail.com>.
Hm, but I have used package variables at Oracle 9 times (with JDBC though,
but iBatis just wraps JDBC) and it worked fine.
May I ask how do you handle transactions, and may I look at the code snippet
calling those procedures?
On Tue, Aug 4, 2009 at 9:44 AM, CuriousMind <yo...@hotmail.com>wrote:
>
> Hi Nichol,
>
> Thanks for your response. We are already using same transaction while
> calling these procedures.
> But we are not getting expected results.
>
>
>
>
> Nicholoz Koka Kiknadze wrote:
> >
> > You are quite right. Your problem is that calls to those two procedures
> > are
> > not in a single transaction. Include them in a single transaction and
> > proc2
> > will see package level variables set in proc1. Note that executing those
> > procs on a single connection object is not enough (i.e. you need
> > transaction).
> >
> > hth
> >
> > On Tue, Aug 4, 2009 at 8:48 AM, CuriousMind
> > <yo...@hotmail.com>wrote:
> >
>
> --
> View this message in context:
> http://www.nabble.com/PL-SQL-package-level-variables-tp24802267p24802615.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>
Re: PL/SQL package level variables
Posted by CuriousMind <yo...@hotmail.com>.
Hi Nichol,
Thanks for your response. We are already using same transaction while
calling these procedures.
But we are not getting expected results.
Nicholoz Koka Kiknadze wrote:
>
> You are quite right. Your problem is that calls to those two procedures
> are
> not in a single transaction. Include them in a single transaction and
> proc2
> will see package level variables set in proc1. Note that executing those
> procs on a single connection object is not enough (i.e. you need
> transaction).
>
> hth
>
> On Tue, Aug 4, 2009 at 8:48 AM, CuriousMind
> <yo...@hotmail.com>wrote:
>
--
View this message in context: http://www.nabble.com/PL-SQL-package-level-variables-tp24802267p24802615.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Re: PL/SQL package level variables
Posted by Nicholoz Koka Kiknadze <ki...@gmail.com>.
You are quite right. Your problem is that calls to those two procedures are
not in a single transaction. Include them in a single transaction and proc2
will see package level variables set in proc1. Note that executing those
procs on a single connection object is not enough (i.e. you need
transaction).
hth
On Tue, Aug 4, 2009 at 8:48 AM, CuriousMind <yo...@hotmail.com>wrote:
>
> Hi,
>
> I am having 3 procedures which i want to call using IBatis framework. These
> procedure are using package level variables and hence when I try to call
> them, it ends up throwing error as the package variable value is not found.
> Consider following scenario for more details
> Package level variable = varPK
> Procedure 1 sets varPK (Package level variable) to "SomeValue"
> Procedure 2 tries to check value of varPK and finds that it is empty.
>
> I know this could be resolved by writing wrapper procedure which will call
> above listed procedure in sequence but I am looking for better solution.
> The
> problem is that I am migrating existing application to Ibatis framework and
> hence it is not possible to find out where such scenarios would come.
> The error that I am facing is probably due to for every call to iBatis API
> gets different connection object (I am using connection pool and spring
> integration with ibatis.). I think this can be resolved only if current
> thread will get same connection instance. Is there any way to ensure that
> the current thread will always receive same connection instance?
> --
> View this message in context:
> http://www.nabble.com/PL-SQL-package-level-variables-tp24802267p24802267.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>