This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

invalid colum name GenericJDBCException: could not execute query

Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need your help.

This the topic:

I am using JPA with Oracle 9i, JBoss 5.x GA and the default provider is Hibernate.

I am working with "Native Query" and my second test for this was a native query with fields of two entities

This is my query

String sql = "SELECT c.firstName as FIRSTNAME, c.lastname as LASTNAME " +
"WHERE c.creditcard_id =";

the two columns selected are from customer table, I had more columns, but I have tested this query because I thought that it will be simplier,

the table CUSTOMER has firstname and lastname columns, and more.
the table CREDITCARD has its columns in form.

When I execute the query as:

Query query = manager.createNativeQuery(sql);

List phones = query.getResultList();
System.out.println("size " + phones.size());

I can see: size 5, the 5 rows in the DB.

And I have not problem if I only get the values as such.

If I make this:

Query query = manager.createNativeQuery(sql,"customerAndCreditCardMapping");

List phones = query.getResultList();
System.out.println("size " + phones.size());

With "customerAndCreditCardMapping" into Customer entity as:

fields={@FieldResult(name="firstName", column="FIRSTNAME"),
@FieldResult(name="lastName", column="LASTNAME")}

I get the next exception:

org.hibernate.exception.GenericJDBCException: could not execute query
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(
at org.hibernate.ejb.QueryImpl.getResultList(
at com.titan.clients.NativeQueries.nativeWithMultipleEntities(
at com.titan.clients.NativeQueries.main(
Caused by: org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(
at org.hibernate.exception.SQLStateConverter.convert(
at org.hibernate.exception.JDBCExceptionHelper.convert(
at org.hibernate.loader.Loader.doList(
at org.hibernate.loader.Loader.listIgnoreQueryCache(
at org.hibernate.loader.Loader.list(
at org.hibernate.loader.custom.CustomLoader.list(
at org.hibernate.impl.SessionImpl.listCustomQuery(
at org.hibernate.impl.AbstractSessionImpl.list(
at org.hibernate.impl.SQLQueryImpl.list(
at org.hibernate.ejb.QueryImpl.getResultList(
... 2 more
Caused by: java.sql.SQLException: Nombre de columna no vĂ¡lido
at oracle.jdbc.dbaccess.DBError.throwSqlException(
at oracle.jdbc.dbaccess.DBError.throwSqlException(
at oracle.jdbc.dbaccess.DBError.throwSqlException(
at oracle.jdbc.driver.OracleStatement.get_column_index(
at oracle.jdbc.driver.OracleResultSetImpl.findColumn(
at oracle.jdbc.driver.OracleResultSet.getLong(
at org.hibernate.type.LongType.get(
at org.hibernate.type.NullableType.nullSafeGet(
at org.hibernate.type.NullableType.nullSafeGet(
at org.hibernate.loader.Loader.getKeyFromResultSet(
at org.hibernate.loader.Loader.getRowFromResultSet(
at org.hibernate.loader.Loader.doQuery(
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(
at org.hibernate.loader.Loader.doList(
... 9 more
Exception in thread "main" javax.persistence.RollbackException: Transaction marked as rollbackOnly
at org.hibernate.ejb.TransactionImpl.commit(
at com.titan.clients.NativeQueries.main(

I ran the SQL from TOAD and it is fine.

The exception is thrown when I try of make the mapping with @SqlResultSetMapping customerAndCreditCardMapping but I don't have idea.


Not so fast naughty spawn! I want you to know about
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic