-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Hibernate just stops
PostPosted: Wed Oct 22, 2003 11:14 am 
Beginner
Beginner

Joined: Mon Sep 29, 2003 2:18 pm
Posts: 20
Below is my mapping and my code, and the output below that. I don't get any output from the "I didn't get here" ... it doesn't get there. and that's bad.

Any ideas?
Steve


<?xml version="1.0" ?>
<!DOCTYPE hibernate-mapping (View Source for full doctype...)>
- <hibernate-mapping default-cascade="none" auto-import="true">
- <class name="com.cti.portal.drugorder.PortalDrugItem" table="PRTL_DRUGS" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false" batch-size="1" select-before-update="false" optimistic-lock="version">
- <composite-id unsaved-value="none">
<key-property name="drugCode" column="DRUG_CODE" />
<key-property name="drugName" column="DRUG_NAME" />
</composite-id>
</class>
</hibernate-mapping>


try {


sess = sessions.openSession(); // obtain a JDBC connection and
// instantiate a new Session

Query q = sess.createQuery(
"from PortalDrugItem as di"
);
System.out.println("I got here");

List result = null;
System.out.println("I got here");
result = q.list();
System.out.println("I didn't get here");
System.out.println(result.size());

ArrayList list = new ArrayList();
Iterator iter = result.iterator();

int i = 0;
while ( iter.hasNext() ) {
System.out.println("Hi");
Object o2 = iter.next();
System.out.println(++i);
if (o2 == null) {
System.out.println("Null o2");
} else {
PortalDrugItem foo = (PortalDrugItem) o2;
System.out.println(foo.getDrugName());
}
}

}
finally {
sess.close();
}


INFO: Starting Coyote HTTP/1.1 on port 8080
Oct 22, 2003 11:09:04 AM org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
Oct 22, 2003 11:09:04 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=30/61 config=C:\www\Tomcat 5.0\bin\..\conf\jk2.properties
Oct 22, 2003 11:09:04 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 24275 ms
Oct 22, 2003 11:09:20 AM net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.0.2
Oct 22, 2003 11:09:20 AM net.sf.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=oracle.jdbc.driver.
Oct 22, 2003 11:09:20 AM net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Oct 22, 2003 11:09:20 AM net.sf.hibernate.cfg.Environment <clinit>
INFO: JVM proxy support: true
Oct 22, 2003 11:09:20 AM net.sf.hibernate.cfg.Configuration addClass
INFO: Mapping resource: com/cti/portal/drugorder/PortalDrugItem.hbm.xml
Oct 22, 2003 11:09:22 AM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: com.cti.portal.drugorder.PortalDrugItem -> PRTL_DRUGS
Oct 22, 2003 11:09:23 AM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Oct 22, 2003 11:09:23 AM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Oct 22, 2003 11:09:23 AM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Oct 22, 2003 11:09:24 AM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.OracleDialect
Oct 22, 2003 11:09:24 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
Oct 22, 2003 11:09:24 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@knoxoatest:1525:prtldev
Oct 22, 2003 11:09:24 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=portal4, password=portal4}
Oct 22, 2003 11:09:24 AM net.sf.hibernate.ps.PreparedStatementCache <init>
INFO: prepared statement cache size: 10
Oct 22, 2003 11:09:24 AM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: Use outer join fetching: true
Oct 22, 2003 11:09:26 AM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: Use scrollable result sets: true
Oct 22, 2003 11:09:26 AM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: JDBC 2 max batch size: 15
Oct 22, 2003 11:09:26 AM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: echoing all SQL to stdout
Oct 22, 2003 11:09:27 AM net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: no JDNI name configured
Oct 22, 2003 11:09:27 AM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: Query language substitutions: {}
I got here
I got here
Hibernate: select portaldr0_.DRUG_CODE as DRUG_CODE, portaldr0_.DRUG_NAME as DRUG_NAME from PRTL_DRUGS portaldr0_


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2003 12:23 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Why don't you add a catch bock with some logs ????
Right now, you swallow any exception silently.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Swallowing catch
PostPosted: Wed Oct 22, 2003 3:08 pm 
Beginner
Beginner

Joined: Mon Sep 29, 2003 2:18 pm
Posts: 20
Umm. All I have is a finally. I'll try it. Maybe there's something I don't understand about Java. But I don't have a catch block in there.

Steve


Top
 Profile  
 
 Post subject: Hmm!
PostPosted: Wed Oct 22, 2003 3:15 pm 
Beginner
Beginner

Joined: Mon Sep 29, 2003 2:18 pm
Posts: 20
Sure enough. It worked. Learn something everyday.

I got this message:

java.lang.ClassCastException: com.cti.portal.drugorder.PortalDrugItem
at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:219)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:154)
at net.sf.hibernate.loader.Loader.find(Loader.java:620)
at net.sf.hibernate.hql.QueryTranslator.find(QueryTranslator.java:928)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1343)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:76)
at org.apache.jsp.hibernate_jsp._jspService(hibernate_jsp.java:76)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2003 3:57 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I bet com.cti.portal.drugorder.PortalDrugItem doesn't implements Serializable

Quote:
Your persistent class must override equals() and hashCode() to implement composite identifier equality. It must also implements Serializable.


See section 4.1.5 of the hibernate reference guide for more details

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.