aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate SQLGrammarException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate SQLGrammarException" Watch "Hibernate SQLGrammarException" New topic
Author

Hibernate SQLGrammarException

Saikat Gupta
Greenhorn

Joined: Jun 07, 2007
Posts: 4
Hi,

I am facing a problem when I try to run this code.

=================My Entity Class==================

==================My hibernate.cfg.xml is as below==================

=======My Service class========================

=================================================
My database structure is like below.

Vehicle
===========
VEHICLE_ID : INT
VEHICLE_NAME: VARCHAR
=====================

Now the problem is when I try to run the service method it throws an error like,


======================

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Hibernate: select * from VEHICLE where VEHICLE_NAME = ?
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2545)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
at org.saikat.javaapps.service.GetVehicle.main(GetVehicle.java:38)
Caused by: java.sql.SQLException: Column 'clazz_' not found.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1056)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:1064)
at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:2830)
at org.hibernate.type.descriptor.sql.IntegerTypeDescriptor$2.doExtract(IntegerTypeDescriptor.java:61)
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:254)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:250)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:235)
at org.hibernate.loader.Loader.getInstanceClass(Loader.java:1589)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1431)
at org.hibernate.loader.Loader.getRow(Loader.java:1355)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:611)
at org.hibernate.loader.Loader.doQuery(Loader.java:829)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2542)
... 7 more

============================================

Please, give me the expected solution.

Saikat

[VK: Added code tags]
Saikat Gupta
Greenhorn

Joined: Jun 07, 2007
Posts: 4
Please help me out of this situation. I still did not have any replies.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate SQLGrammarException