-->
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.  [ 3 posts ] 
Author Message
 Post subject: Column not found error: org.hibernate.exception.GenericJDBC
PostPosted: Fri Aug 14, 2009 10:01 am 
Newbie

Joined: Tue Jun 09, 2009 7:54 am
Posts: 10
Hi all,

I am stuck with this since a very long time. I am getting this error for an HQL or a native sql query in hibernate. I

request you to help me. I am unable to find the post where this has been discussed before. Kindly help!


Error
Code:
INFO: Not binding factory to JNDI, no JNDI name configured
Aug 14, 2009 7:04:57 PM org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named queries
Hibernate: select user0_.USERNAME from USER user0_
Aug 14, 2009 7:04:58 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 0, SQLState: S0022
Aug 14, 2009 7:04:58 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Column 'col_0_0_' not found.
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute query
   at

org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
   at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.loader.Loader.doList(Loader.java:1518)
   at org.hibernate.loader.Loader.list(Loader.java:1498)
   at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:369)
   at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:266)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:788)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
   at myapp.test.dao.HibernateDAO.validatePassword(HibernateDAO.java:41)
   at myapp.test.dao.HibernateDAO.main(HibernateDAO.java:468)
Caused by: java.sql.SQLException: Column 'col_0_0_' not found.
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
   at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:970)
   at com.mysql.jdbc.ResultSet.getString(ResultSet.java:5613)
   at org.hibernate.type.StringType.get(StringType.java:16)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
   at org.hibernate.loader.hql.QueryLoader.getResultColumnOrRow(QueryLoader.java:320)
   at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:313)
   at org.hibernate.loader.Loader.doQuery(Loader.java:387)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:206)
   at org.hibernate.loader.Loader.doList(Loader.java:1515)
   ... 7 more


Code
Code:
public User validatePassword(String username, String password){      
      String QUERY = "select username from User";
      Query query = session.createQuery(QUERY);
      session = HibernateInitializer.getSession();
      
      List<Object[]> data = (List<Object[]>)query.list();
      Iterator<Object[]> it = data.iterator();
      User user = null;
      try {
         while(it.hasNext()) {
            Object[] row = (Object[]) it.next();      
            user = new User();
            user.setUsername((String)row[0]);
               
         }
      } catch (Exception e) {
         e.printStackTrace();
      }      
      finally {
         session.flush();
         session.close();
      }
      return user;      
   }



xml files

Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
      <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
      <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
      <property name="hibernate.connection.username">root</property>
      <property name="hibernate.connection.password">root</property>
      <property name="hibernate.connection.pool_size">10</property>
      <property name="show_sql">true</property>
      <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
     
     <mapping resource="user.hbm.xml"/>
  </session-factory>
</hibernate-configuration>





Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
  <class name="User" table="USER">
   <id name="username" column="USERNAME">
 
  </id>

</class>
</hibernate-mapping>




Top
 Profile  
 
 Post subject: Re: Column not found error: org.hibernate.exception.GenericJDBC
PostPosted: Sat Aug 15, 2009 6:32 am 
Newbie

Joined: Tue Jun 09, 2009 7:54 am
Posts: 10
Can someone please help! I am a newbie..Thanks!


namrata014 wrote:
Hi all,

I am stuck with this since a very long time. I am getting this error for an HQL or a native sql query in hibernate. I

request you to help me. I am unable to find the post where this has been discussed before. Kindly help!


Error
Code:
INFO: Not binding factory to JNDI, no JNDI name configured
Aug 14, 2009 7:04:57 PM org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named queries
Hibernate: select user0_.USERNAME from USER user0_
Aug 14, 2009 7:04:58 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 0, SQLState: S0022
Aug 14, 2009 7:04:58 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Column 'col_0_0_' not found.
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute query
   at

org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
   at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.loader.Loader.doList(Loader.java:1518)
   at org.hibernate.loader.Loader.list(Loader.java:1498)
   at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:369)
   at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:266)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:788)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
   at myapp.test.dao.HibernateDAO.validatePassword(HibernateDAO.java:41)
   at myapp.test.dao.HibernateDAO.main(HibernateDAO.java:468)
Caused by: java.sql.SQLException: Column 'col_0_0_' not found.
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
   at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:970)
   at com.mysql.jdbc.ResultSet.getString(ResultSet.java:5613)
   at org.hibernate.type.StringType.get(StringType.java:16)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
   at org.hibernate.loader.hql.QueryLoader.getResultColumnOrRow(QueryLoader.java:320)
   at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:313)
   at org.hibernate.loader.Loader.doQuery(Loader.java:387)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:206)
   at org.hibernate.loader.Loader.doList(Loader.java:1515)
   ... 7 more


Code
Code:
public User validatePassword(String username, String password){      
      String QUERY = "select username from User";
      Query query = session.createQuery(QUERY);
      session = HibernateInitializer.getSession();
      
      List<Object[]> data = (List<Object[]>)query.list();
      Iterator<Object[]> it = data.iterator();
      User user = null;
      try {
         while(it.hasNext()) {
            Object[] row = (Object[]) it.next();      
            user = new User();
            user.setUsername((String)row[0]);
               
         }
      } catch (Exception e) {
         e.printStackTrace();
      }      
      finally {
         session.flush();
         session.close();
      }
      return user;      
   }



xml files

Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
      <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
      <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
      <property name="hibernate.connection.username">root</property>
      <property name="hibernate.connection.password">root</property>
      <property name="hibernate.connection.pool_size">10</property>
      <property name="show_sql">true</property>
      <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
     
     <mapping resource="user.hbm.xml"/>
  </session-factory>
</hibernate-configuration>





Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
  <class name="User" table="USER">
   <id name="username" column="USERNAME">
 
  </id>

</class>
</hibernate-mapping>




Top
 Profile  
 
 Post subject: Re: Column not found error: org.hibernate.exception.GenericJDBC
PostPosted: Fri Sep 04, 2009 10:08 am 
Newbie

Joined: Fri Sep 04, 2009 10:04 am
Posts: 10
Hey, Did you get the solution for this, if yes can you share that information .

Thank you


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