Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Spring: getHibernateTemplate().loadAll(clazz); failing
PostPosted: Mon May 16, 2005 1:24 am 
Newbie

Joined: Fri Feb 04, 2005 4:27 pm
Posts: 3
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


[b]Spring version:[/b]
1.2

[b]Hibernate version:[/b]
3.0.3

[b]JDK version:[/b]
1.4 (same problem w/1.5)

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

[b]Simple model object:[/b]

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;
}

[b]Mapping documents:[/b]

<?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>


[b]Code between sessionFactory.openSession() and session.close():[/b]

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);
}
....
}

[b]Full stack trace of any exception that occurs:[/b]
See log.

[b]The generated SQL (show_sql=true):[/b]

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

[b]Debug level Hibernate log excerpt:[/b]

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(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
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.java:1253)
at oracle.jdbc.driver.OracleResultSetImpl.next(OracleResultSetImpl.java:295)
at org.hibernate.loader.Loader.doQuery(Loader.java:391)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:210)
at org.hibernate.loader.Loader.doList(Loader.java:1562)
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.java:1316)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:299)
at org.springframework.orm.hibernate3.HibernateTemplate$5.doInHibernate(HibernateTemplate.java:452)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:311)
at org.springframework.orm.hibernate3.HibernateTemplate.loadAll(HibernateTemplate.java:448)
at com.lucent.qip.monarch.dao.impl.BaseDaoImpl.loadList(BaseDaoImpl.java:25)
at test.com.lucent.qip.monarch.dao.DummyObjectDaoTest.testLoadList(DummyObjectDaoTest.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.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.java: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:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.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


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 16, 2005 1:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
hibernate.use_sql_comments false


Top
 Profile  
 
 Post subject: Nothing like success!
PostPosted: Mon May 16, 2005 10:12 am 
Newbie

Joined: Fri Feb 04, 2005 4:27 pm
Posts: 3
Gavin,

You’re the man. Setting ‘hibernate.use_sql_comments=false’ did the trick. Many thanks for your rapid response.

Best,
Chip


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 5:02 pm 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
Heh, gotta love the succinctness of Gavin's responses. They are short and right to the point. :-) So, is this a known bug (I'm using 3.0.3)? I seem to recall running into this issue previously and just ran into it again now. The comments are very helpful IMHO, so, I hate to turn them off.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.