Results 1 to 3 of 3

Thread: Hibernate 4 and MyBatis in same appication

  1. #1
    Join Date
    Jun 2008
    Posts
    7

    Default 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.

  2. #2
    Join Date
    Jun 2008
    Posts
    7

    Default

    Any ideas?

  3. #3
    Join Date
    Mar 2006
    Location
    Oslo, Norway
    Posts
    15

    Default

    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
  •