ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Kratz <jason.kr...@firm58.com>
Subject strange issue with sqlmapsession
Date Fri, 01 Aug 2008 21:01:56 GMT
Hi all...

I'm using iBATIS with Spring and am having an odd issue that I'm not  
sure how to resolve.

We have an oracle DataSource where we have to set a client identifier  
which is used by the row-level security feature of oracle when we get  
connections from the datasource.  When we construct the sqlmapdao we  
call getSqlMapClientTemplate().getSqlMapClient().setUserConnection().   
In our Weblogic environment this works fine but we are having problems  
in a junit environment (using the same connection handling but with  
Spring's testing framework.  The problem is that when the oracle row- 
level security is enabled we aren't seeing any rows which means the  
client identifier isn't being set when running unit tests.

When we run a queryForList it ends up hitting the execute() method of  
the SqlMapClientTemplate from Spring.  The first thing that method  
does is call SqlMapSession session = this.sqlMapClient.openSession();  
and this seems to be the ultimate source of the problem.   Why?   
Because the localSqlMapSession that is stored in a ThreadLocal when we  
call sqlMapClient().setUserConnection() is never checked when  
sqlMapClient.openSession() is called.    
sqlMapClient.setUserConnection() first checks for a localSqlMapSession  
and creates one if one isn't already present.  But for some reason it  
seems that that localSqlMapSession is never actually used anywhere  
(unless I'm missing something but I was looking at the references of  
the objects themselves and nothing was matching what was originally  
created when I called setUserConnection() on the sqlMapClient the  
first time).  I seem to be getting a new connection to the database  
which doesn't have the oracle-specific client identifier stored and  
this means we get no data back.

Now....I'm not sure why this doesn't happen inside of our weblogic  
environment but the config for ibatis is a bit different.  In the  
sqlMapConfig for weblogic we are specifying a transactionManager type  
of EXTERNAL.  We aren't in the unit testing setup but I was under the  
impression that the spring defaulted to an EXTERNAL transactionManager  
anyhow when the sqlmapclientfactorybean builds sqlmapclient objects.

This is probably pretty confusing so I can clarify if need be ;) Also,  
this happens with both release 2.3.3 and 2.3.0.

Thanks,

Jason
Mime
View raw message