Announcement Announcement Module
Collapse
No announcement yet.
Hibernate 4 and MyBatis in same appication Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Any ideas?

    Comment


    • #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

      Comment

      Working...
      X