Hibernate Spatial

Exception using connection pool in Jboss 6.0 and Oracle 10g

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: 1.1
  • Fix Version/s: 1.1.1
  • Component/s: Oracle10g
  • Description:
    Hide
    When I using Hibernate Spatial 1.1 in Jboss 6.0 and Oracle 10g, HS throwsthe following exception:

    Caused by: java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6 cannot be cast to oracle.jdbc.OracleConnection
    at oracle.sql.STRUCT.<init>(STRUCT.java:142)
    at org.hibernatespatial.oracle.OracleJDBCTypeFactory.createStruct(OracleJDBCTypeFactory.java:51)
    at org.hibernatespatial.oracle.SDOGeometry.store(SDOGeometry.java:154)
    at org.hibernatespatial.oracle.SDOGeometryType.conv2DBGeometry(SDOGeometryType.java:82)
    at org.hibernatespatial.oracle.SDOGeometryType.nullSafeSet(SDOGeometryType.java:72)
    at org.hibernatespatial.GeometryUserType.nullSafeSet(GeometryUserType.java:198)
    at org.hibernate.type.CustomType.nullSafeSet(CustomType.java:140)
    at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2166)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2412)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2856)
    at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
    at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:117)


    I believe the problem occurs because the Oracle connetion is not passed in the constructor oracle struct. The code below seems to solve the problem.

    public Struct createStruct(SDOGeometry geom, Connection conn) throws SQLException {
            OracleConnection oracleConnection = null;
            try {
                oracleConnection = connectionFinder.find(conn);
            } catch (FinderException e) {
                throw new HibernateException("Problem finding Oracle Connection", e);
            }
            StructDescriptor structDescriptor = StructDescriptor
                    .createDescriptor(SDOGeometryType.SQL_TYPE_NAME, oracleConnection);
            Object[] attributes = new Datum[5];
            attributes[0] = new NUMBER(geom.getGType().intValue());
            if (geom.getSRID() > 0) {
                attributes[1] = new NUMBER(geom.getSRID());
            } else {
                attributes[1] = null;
            }
            attributes[3] = createElemInfoArray(geom.getInfo(), oracleConnection);
            attributes[4] = createOrdinatesArray(geom.getOrdinates(), oracleConnection);
            return new STRUCT(structDescriptor, oracleConnection, attributes); //<-- using Oracle connection here
        }


    Show
    When I using Hibernate Spatial 1.1 in Jboss 6.0 and Oracle 10g, HS throwsthe following exception: Caused by: java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6 cannot be cast to oracle.jdbc.OracleConnection at oracle.sql.STRUCT.<init>(STRUCT.java:142) at org.hibernatespatial.oracle.OracleJDBCTypeFactory.createStruct(OracleJDBCTypeFactory.java:51) at org.hibernatespatial.oracle.SDOGeometry.store(SDOGeometry.java:154) at org.hibernatespatial.oracle.SDOGeometryType.conv2DBGeometry(SDOGeometryType.java:82) at org.hibernatespatial.oracle.SDOGeometryType.nullSafeSet(SDOGeometryType.java:72) at org.hibernatespatial.GeometryUserType.nullSafeSet(GeometryUserType.java:198) at org.hibernate.type.CustomType.nullSafeSet(CustomType.java:140) at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2166) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2412) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2856) at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383) at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:117) I believe the problem occurs because the Oracle connetion is not passed in the constructor oracle struct. The code below seems to solve the problem. public Struct createStruct(SDOGeometry geom, Connection conn) throws SQLException {         OracleConnection oracleConnection = null;         try {             oracleConnection = connectionFinder.find(conn);         } catch (FinderException e) {             throw new HibernateException("Problem finding Oracle Connection", e);         }         StructDescriptor structDescriptor = StructDescriptor                 .createDescriptor(SDOGeometryType.SQL_TYPE_NAME, oracleConnection);         Object[] attributes = new Datum[5];         attributes[0] = new NUMBER(geom.getGType().intValue());         if (geom.getSRID() > 0) {             attributes[1] = new NUMBER(geom.getSRID());         } else {             attributes[1] = null;         }         attributes[3] = createElemInfoArray(geom.getInfo(), oracleConnection);         attributes[4] = createOrdinatesArray(geom.getOrdinates(), oracleConnection);         return new STRUCT(structDescriptor, oracleConnection, attributes); //<-- using Oracle connection here     }
  • Environment:
    Jboss 6.0, Oracle 10g

Issue Links

Activity

This list of changesets may be incomplete, as errors occurred retrieving changesets from the following repositories:
No related commits found.

People

Dates

  • Created:
    12/Jun/11 6:56 PM
    Updated:
    22/Jun/11 11:14 AM
    Resolved:
    22/Jun/11 11:14 AM