-->
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.  [ 1 post ] 
Author Message
 Post subject: query problem (Column not found)
PostPosted: Sun Jun 20, 2004 8:01 am 
Newbie

Joined: Sun Jun 20, 2004 7:41 am
Posts: 7
Hi all,

I'm going through the examples from the book "Java Open Source Programming with XDoclet, JUnit, WebWork, Hibernate".

I get "net.sf.hibernate.JDBCException: Could not execute query" every time I'm trying to execute a query like

List ret = session.find("from ContactInfo");

the code that executes is:


public static void main(String[] args) throws Exception {

Configuration config = new Configuration();
SessionFactory sf;
Session session=null;

try {
config.configure();
sf = config.buildSessionFactory();
session = sf.openSession();
List ret = session.find("from ContactInfo");
} catch (HibernateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
session.connection().rollback();
}


The first lines of the stack trace are:

Hibernate: select contactinf0_.PK as PK, contactinf0_.FNAME as FNAME, contactinf0_.LNAME as LNAME, contactinf0_.PHONEAREACODE as PHONEARE4_, contactinf0_. PHONECOUNTRYCODE as PHONECO5_, contactinf0_.PHONENUMBER as PHONENUM6_ from CONTACT contactinf0_
net.sf.hibernate.JDBCException: Could not execute query
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1546)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1520)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
at com.hicnar.hibernate.TestIt2.main(TestIt2.java:52)
Caused by: java.sql.SQLException: Column ' PHONECO5_' not found.
at org.objectweb.cjdbc.driver.DriverResultSet.findColumn(DriverResultSet.java:2320)
at org.objectweb.cjdbc.driver.DriverResultSet.getString(DriverResultSet.java:884)
at net.sf.hibernate.type.StringType.get(StringType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)

If I take the query generated by Hibernate (select contactinf0_.PK as PK, contactinf0_.FNAME as FNAME, contactinf0_.LNAME as LNAME, contactinf0_.PHONEAREACODE as PHONEARE4_, contactinf0_. PHONECOUNTRYCODE as PHONECO5_, contactinf0_.PHONENUMBER as PHONENUM6_ from CONTACT contactinf0_) and paste it in the sql console (I use PostgreSQL) it works fine.


the hibernate.cfg.xml looks like follows:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory name="/jndi/ContactsSessionFactory">
<!-- properties -->
<property name="hibernate.connection.driver_class">
<!-- org.objectweb.cjdbc.driver.Driver -->
org.postgresql.Driver
</property>
<property name="hibernate.connection.url">
<!-- jdbc:cjdbc://localhost:25322/hibernateTest -->
jdbc:postgresql://127.0.0.1/hibertest
</property>
<property name="hibernate.connection.username">username</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.dialect">
net.sf.hibernate.dialect.PostgreSQLDialect
</property>
<property name="hibernate.connection.pool_size">4</property>
<property name="hibernate.show_sql">true</property>
<!-- mapping files -->
<mapping resource="com/hicnar/hibernate/ContactInfo.hbm.xml"/>
<mapping resource="com/hicnar/hibernate/Folder.hbm.xml"/>
</session-factory>
</hibernate-configuration>



Any suggestions would be appreciated.

Chris


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.