-
Jul 13th, 2012, 03:27 AM
#1
Hibernate 4 and MyBatis in same appication
Hi,
We use Hibernate 3, MyBatis 3 and HibernateTransactionManager in same application. All work fine.
But, after migration to Spring 3.1 and Hibernate 4 We have a following problem:
We use custom type handler for MyBatis to pass the Oracle ARRAY.
public class ArrayTypeHandler extends AbstractTypeHandler<Object> {
private static final String NUM_ARRAY = "T_NUM_ARRAY";
@Override
public void setParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException {
Connection conn = ps.getConnection();
ArrayDescriptor desc = ArrayDescriptor.createDescriptor(NUM_ARRAY, conn);
ps.setArray(i, new ARRAY(desc, conn, ((Collection<?>)parameter).toArray()));
}
}
But, after migration ps.getConnection() return proxy for ConnectionProxyHandler (Hibernate) instead internal Oracle connection that required for ArrayDescriptor.
Can I get the internal connection if I use HibernateTransactionManager for MyBatis?
Or maybe there are other solutions to the problem?
Thanks.
-
Jul 24th, 2012, 03:34 AM
#2
-
Sep 24th, 2012, 05:40 AM
#3
Hi,
You can always try to cast the ConnectionProxyHandler to org.hibernate.engine.jdbc.spi.JdbcWrapper, and invoke the getWrappedObject() to get access to the internal connection. Hope it helps...
Regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules