Announcement Announcement Module
Collapse
No announcement yet.
HibernateTemplate.loadAll(Class clazz): failing on Oracle 9i Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HibernateTemplate.loadAll(Class clazz): failing on Oracle 9i

    I'm running a Spring managed Hibernate session on a Oracle 9i DB. Calling Spring's 'getHibernateTemplate.loadAll()' function causes the Oracle 'ORA-01009' exception shown below.

    -------------------------

    JDBCExceptionReporter:63 - could not execute query
    [/*criteria query*/select this_.ID as ID0_, this_.NAME as NAME0_0_
    from MONADMIN.DUMMYOBJECT this_]

    java.sql.SQLException: ORA-01009: missing mandatory parameter

    -------------------------

    This same error occurs for other HibernateTemplate methods that take
    a Class argument as well.

    e.g. load(Class clazz, Serialized arg);
    get (Class clazz, Serialized arg);

    -------------------------

    I'm running out of ideas as to what the root cause is. I've tried changing
    Oracle thin driver versions and rebuilding my app under JDK1.4 and 1.5.

    If anyone out there knows of a work around or could help me understand what's going on I'd be very grateful. More code and log output appears below.

    Thanks,
    Chip Powell


    Spring version:
    1.2

    Hibernate version:
    3.0.3

    JDK version:
    1.4 (same problem w/1.5)

    Name and version of the database you are using:
    Oracle 9.2.0.1.0
    oracle.jdbc.driver.OracleDriver (ojdbc14.zip)

    Simple model object:

    public class DummyObject extends BaseObject {
    private Long id;
    private String name;

    public DummyObject() {
    super();
    }

    /**
    * @hibernate.id
    * column="ID"
    * unsaved-value="null"
    * generator-class="native"
    *
    * @return Returns the id.
    */
    public Long getId() {
    return id;
    }

    /**
    * @param id The id to set.
    */
    public void setId(Long id) {
    this.id = id;
    }

    /**
    * @hibernate.property
    * column="NAME"
    * not-null="true"
    * unique="true"
    *
    * @return Returns the name.
    */
    public String getName() {
    return name;
    }

    /**
    * @param name The name to set.
    */
    public void setName(String name) {
    this.name = name;
    }

    Mapping documents:

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

    <hibernate-mapping
    >
    <class
    name="com.lucent.qip.monarch.model.DummyObject"
    table="DUMMYOBJECT"
    dynamic-update="true"
    dynamic-insert="true"
    >
    <cache usage="read-write" />

    <id
    name="id"
    column="ID"
    type="java.lang.Long"
    unsaved-value="null"
    >
    <generator class="native">
    <!--
    To add non XDoclet generator parameters, create a file named
    hibernate-generator-params-DummyObject.xml
    containing the additional parameters and place it in your merge dir.
    -->
    </generator>
    </id>

    <property
    name="name"
    type="java.lang.String"
    update="true"
    insert="true"
    column="NAME"
    not-null="true"
    unique="true"
    />

    <!--
    To add non XDoclet property mappings, create a file named
    hibernate-properties-DummyObject.xml
    containing the additional properties and place it in your merge dir.
    -->

    </class>

    </hibernate-mapping>


    Code between sessionFactory.openSession() and session.close():

    Spring handles session management, the following code shows a JUnit
    test case that triggers the problem.

    public class DummyObjectDaoTest {
    ApplicationContext ctx = new ClassPathXmlApplicationContext
    ("applicationContext.xml");

    DummyObjectDao dao = (DummyObjectDao) ctx.getBean
    ("dummyObjectDao");

    DummyObject = obj;

    // save some objects
    for (int i= 1; j < 3; i++) {
    obj = new DummyObject();
    obj.setName("Object" + i);

    dao.save(obj); // this works ok
    }

    // read them back
    List objects = dao.loadList(DummyObject.class); // error call
    ...
    }

    public class BaseDaoImpl extends HibernateDaoSupport
    implements BaseDao {
    ...
    public List loadList(Class clazz) {
    return getHibernateTemplate().loadAll(clazz);
    }
    ....
    }

    Full stack trace of any exception that occurs:
    See log.

    The generated SQL (show_sql=true):

    [/*criteria query*/select this_.ID as ID0_, this_.NAME as NAME0_0_ from MONADMIN.DUMMYOBJECT this_]

    Debug level Hibernate log excerpt:

    00:29:29,361 DEBUG SessionImpl:248 - opened session at timestamp: 4572027983302656
    00:29:29,455 DEBUG AbstractBatcher:277 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    00:29:29,471 DEBUG AbstractBatcher:422 - opening JDBC connection
    00:29:35,736 DEBUG SQL:311 - /*criteria query*/select this_.ID as ID0_, this_.NAME as NAME0_0_ from MONADMIN.DUMMYOBJECT this_
    Hibernate: /*criteria query*/select this_.ID as ID0_, this_.NAME as NAME0_0_ from MONADMIN.DUMMYOBJECT this_
    00:29:35,736 DEBUG AbstractBatcher:365 - preparing statement
    00:29:35,752 DEBUG AbstractBatcher:293 - about to open ResultSet (open ResultSets: 0, globally: 0)
    00:29:35,752 DEBUG Loader:388 - processing result set
    00:29:35,877 DEBUG AbstractBatcher:300 - about to close ResultSet (open ResultSets: 1, globally: 1)
    00:29:35,892 DEBUG AbstractBatcher:285 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    00:29:35,892 DEBUG AbstractBatcher:403 - closing statement
    00:29:35,924 DEBUG JDBCExceptionReporter:63 - could not execute query [/*criteria query*/select this_.ID as ID0_, this_.NAME as NAME0_0_ from MONADMIN.DUMMYOBJECT this_]
    java.sql.SQLException: ORA-01009: missing mandatory parameter

    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:2 89)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol .java:1986)
    at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.j ava:1253)
    at oracle.jdbc.driver.OracleResultSetImpl.next(Oracle ResultSetImpl.java:295)
    at org.hibernate.loader.Loader.doQuery(Loader.java:39 1)
    at org.hibernate.loader.Loader.doQueryAndInitializeNo nLazyCollections(Loader.java:210)
    at org.hibernate.loader.Loader.doList(Loader.java:156 2)
    at org.hibernate.loader.Loader.list(Loader.java:1545)
    at org.hibernate.loader.criteria.CriteriaLoader.list( CriteriaLoader.java:111)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.ja va:1316)
    at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl. java:299)
    at org.springframework.orm.hibernate3.HibernateTempla te$5.doInHibernate(HibernateTemplate.java:452)
    at org.springframework.orm.hibernate3.HibernateTempla te.execute(HibernateTemplate.java:311)
    at org.springframework.orm.hibernate3.HibernateTempla te.loadAll(HibernateTemplate.java:448)
    at com.lucent.qip.monarch.dao.impl.BaseDaoImpl.loadLi st(BaseDaoImpl.java:25)
    at test.com.lucent.qip.monarch.dao.DummyObjectDaoTest .testLoadList(DummyObjectDaoTest.java:32)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at junit.framework.TestCase.runTest(TestCase.java:154 )
    at junit.framework.TestCase.runBare(TestCase.java:127 )
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at junit.framework.TestResult.run(TestResult.java:109 )
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:474)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:342)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:194)
    00:29:35,939 WARN JDBCExceptionReporter:71 - SQL Error: 1009, SQLState: 72000
    00:29:35,939 ERROR JDBCExceptionReporter:72 - ORA-01009: missing mandatory parameter

    00:29:35,955 DEBUG JDBCContext:281 - after autocommit
    00:29:35,955 DEBUG AbstractBatcher:437 - closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
    00:29:35,971 DEBUG SessionImpl:399 - after transaction completion
    00:29:35,971 DEBUG SessionImpl:265 - closing session

  • #2
    Adding your reply at Hibernate
    - http://forum.hibernate.org/viewtopic.php?t=942454

    Comment


    • #3
      Nothng like success!

      Per Gavin King:

      Setting 'hibernate.use_sql_comments=false' in hibernate.properties fixes the problem.

      Chip

      Comment

      Working...
      X