-->
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.  [ 12 posts ] 
Author Message
 Post subject: Getting error as org.hibernate.hql.ast.ErrorCounter reportEr
PostPosted: Thu Jan 22, 2009 1:23 am 
Newbie

Joined: Thu Jan 22, 2009 1:12 am
Posts: 7
Location: India
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.3GA

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>

<session-factory>
<property name="connection.username">root</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/orbisdb
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="myeclipse.connection.profile">mysql</property>
<property name="connection.password">orbis</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="show_sql">true</property>

<property name="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</property>

<property name="current_session_context_class">thread</property>
<property name="hibernate.transaction.factory">org.hibernate.transaction.JDBCTransactionFactory</property>

<mapping resource="conf/hbm/AccountType.hbm.xml" />
<mapping resource="conf/hbm/Customer.hbm.xml" />
<mapping resource="conf/hbm/DefDynafield.hbm.xml" />
<mapping resource="conf/hbm/DefEvent.hbm.xml" />
<mapping resource="conf/hbm/DefPhoneConfiguration.hbm.xml" />
<mapping resource="conf/hbm/DefWorkflow.hbm.xml" />
<mapping resource="conf/hbm/DynafieldType.hbm.xml" />
<mapping resource="conf/hbm/hibernate.cfg.xml" />
<mapping resource="conf/hbm/Landmark.hbm.xml" />
<mapping resource="conf/hbm/Locale.hbm.xml" />
<mapping resource="conf/hbm/PhoneAppVersion.hbm.xml" />
<mapping resource="conf/hbm/PhoneConfiguration.hbm.xml" />
<mapping resource="conf/hbm/PhoneModel.hbm.xml" />
<mapping resource="conf/hbm/Picture.hbm.xml" />
<mapping resource="conf/hbm/SuperUser.hbm.xml" />
<mapping resource="conf/hbm/Tracking.hbm.xml" />
<mapping resource="conf/hbm/User.hbm.xml" />
<mapping resource="conf/hbm/UserType.hbm.xml" />
<mapping resource="conf/hbm/WebConfiguration.hbm.xml" />
<mapping resource="conf/hbm/WorkflowEventData.hbm.xml" />
<mapping resource="conf/hbm/WorkflowEventInstance.hbm.xml" />
<mapping resource="conf/hbm/WorkflowInstance.hbm.xml" />
<mapping resource="conf/hbm/Team.hbm.xml" />
</session-factory>
</hibernate-configuration>



Code between sessionFactory.openSession() and session.close():package conf.hbm;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;

/**
* Configures and provides access to Hibernate sessions, tied to the
* current thread of execution. Follows the Thread Local Session
* pattern, see {@link http://hibernate.org/42.html }.
*/
public class HibernateSessionFactory {

/**
* Location of hibernate.cfg.xml file.
* Location should be on the classpath as Hibernate uses
* #resourceAsStream style lookup for its configuration file.
* The default classpath location of the hibernate config file is
* in the default package. Use #setConfigFile() to update
* the location of the configuration file for the current session.
*/
private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";
private static final ThreadLocal<Session> threadLocal = new ThreadLocal<Session>();
private static Configuration configuration = new Configuration();
private static org.hibernate.SessionFactory sessionFactory;
private static String configFile = CONFIG_FILE_LOCATION;

static {
try {
configuration.configure(configFile);
sessionFactory = configuration.buildSessionFactory();
} catch (Exception e) {
System.err
.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
private HibernateSessionFactory() {
}

/**
* Returns the ThreadLocal Session instance. Lazy initialize
* the <code>SessionFactory</code> if needed.
*
* @return Session
* @throws HibernateException
*/
public static Session getSession() throws HibernateException {
Session session = (Session) threadLocal.get();

if (session == null || !session.isOpen()) {
if (sessionFactory == null) {
rebuildSessionFactory();
}
session = (sessionFactory != null) ? sessionFactory.openSession()
: null;
threadLocal.set(session);
}

return session;
}

/**
* Rebuild hibernate session factory
*
*/
public static void rebuildSessionFactory() {
try {
configuration.configure(configFile);
sessionFactory = configuration.buildSessionFactory();
} catch (Exception e) {
System.err
.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}

/**
* Close the single hibernate session instance.
*
* @throws HibernateException
*/
public static void closeSession() throws HibernateException {
Session session = (Session) threadLocal.get();
threadLocal.set(null);

if (session != null) {
session.close();
}
}

/**
* return session factory
*
*/
public static org.hibernate.SessionFactory getSessionFactory() {
return sessionFactory;
}

/**
* return session factory
*
* session factory will be rebuilded in the next call
*/
public static void setConfigFile(String configFile) {
HibernateSessionFactory.configFile = configFile;
sessionFactory = null;
}

/**
* return hibernate configuration
*
*/
public static Configuration getConfiguration() {
return configuration;
}

}


Jan 22, 2009 10:25:55 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: in.omt.model.WorkflowEventInstance.workflowEventDatas -> workflow_event_data
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: in.omt.model.WorkflowInstance.workflowEventInstances -> workflow_event_instance
Jan 22, 2009 10:25:55 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Jan 22, 2009 10:25:55 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Jan 22, 2009 10:25:55 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Jan 22, 2009 10:25:55 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/orbisdb
Jan 22, 2009 10:25:55 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=****}
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.0.67-community-nt
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.7 ( Revision: ${svn.Revision} )
Jan 22, 2009 10:25:55 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
Jan 22, 2009 10:25:55 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
Jan 22, 2009 10:25:55 AM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Jan 22, 2009 10:25:55 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory createRegionFactory
INFO: Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
Jan 22, 2009 10:25:55 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
Jan 22, 2009 10:25:56 AM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Jan 22, 2009 10:25:56 AM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Jan 22, 2009 10:26:00 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: Starting Coyote HTTP/1.1 on http-8080
Jan 22, 2009 10:26:02 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jan 22, 2009 10:26:02 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/62 config=null
Jan 22, 2009 10:26:02 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 12598 ms
Jan 22, 2009 10:26:18 AM org.hibernate.hql.ast.ErrorCounter reportError
SEVERE: line 1:8: unexpected token: in
Jan 22, 2009 10:26:18 AM org.hibernate.hql.ast.ErrorCounter reportError
SEVERE: line 1:8: unexpected token: in



Name and version of the database you are using:Mysql 5.0

My query
String hql1 = "update PhoneConfiguration p set p.intParamValue = :newName where p.paramName = :name and p.customerId = :customer";
Query query1 = session.createQuery(hql);
query.setString("newName",token2);
query.setString("name","TRACKING_START_TIME");
query.setString("customer","2");
int rowCount1 = query.executeUpdate();







Read this: http://hibernate.org/42.html

_________________
Don't loose hope.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 3:34 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Are you sure, that this query is causing your error? Do have some named queries in your mapping resources, which could cause the error? The error says unexpted token "in" but there is no "in" in your query.

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 3:50 am 
Newbie

Joined: Thu Jan 22, 2009 1:12 am
Posts: 7
Location: India
ya this is the only one query I am having, I also tried for searching token in there. I think some think went wrong with cfg files . Is this update query is fine concern to hibernate ? anything parsing probelm with antlr.jar .I'm using antlr-2.7.2.jar

_________________
Don't loose hope.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 3:51 am 
Newbie

Joined: Thu Jan 22, 2009 1:12 am
Posts: 7
Location: India
ya this is the only one query I am having, I also tried for searching token in there. I think some think went wrong with cfg files . Is this update query is fine concern to hibernate ? anything parsing problem with antlr.jar .I'm using antlr-2.7.2.jar

_________________
Don't loose hope.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 3:59 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
I don't think there is anything wrong with antlr. I still believe there is another named-query in one of your mappings. Try to search for "query" or "<query" in your project.

By the way, <mapping resource="conf/hbm/hibernate.cfg.xml" /> looks weird to me. Your hibernate-configuration is not a mapping-resource.

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 4:11 am 
Newbie

Joined: Thu Jan 22, 2009 1:12 am
Posts: 7
Location: India
here <mapping resource="conf/hbm/hibernate.cfg.xml" /> is the folder structure where hibernate.cfg.xml is residing . Having only one query there.

_________________
Don't loose hope.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 4:34 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Yogiraj wrote:
here <mapping resource="conf/hbm/hibernate.cfg.xml" /> is the folder structure where hibernate.cfg.xml is residing

This line is part of your hibernate.cfg.xml, isn't it? <mapping resource> defines a file, where your class-mappings are stored. "hibernate.cfg.xml" is not a class mapping. I hope you understand what I mean: there could also be a query somewhere in the other mapping files:
Code:
<mapping resource="conf/hbm/AccountType.hbm.xml" />
<mapping resource="conf/hbm/Customer.hbm.xml" />
<mapping resource="conf/hbm/DefDynafield.hbm.xml" />
<mapping resource="conf/hbm/DefEvent.hbm.xml" />
<mapping resource="conf/hbm/DefPhoneConfiguration.hbm.xml" />
<mapping resource="conf/hbm/DefWorkflow.hbm.xml" />
<mapping resource="conf/hbm/DynafieldType.hbm.xml" />

<mapping resource="conf/hbm/Landmark.hbm.xml" />
<mapping resource="conf/hbm/Locale.hbm.xml" />
<mapping resource="conf/hbm/PhoneAppVersion.hbm.xml" />
<mapping resource="conf/hbm/PhoneConfiguration.hbm.xml" />
<mapping resource="conf/hbm/PhoneModel.hbm.xml" />
<mapping resource="conf/hbm/Picture.hbm.xml" />
<mapping resource="conf/hbm/SuperUser.hbm.xml" />
<mapping resource="conf/hbm/Tracking.hbm.xml" />
<mapping resource="conf/hbm/User.hbm.xml" />
<mapping resource="conf/hbm/UserType.hbm.xml" />
<mapping resource="conf/hbm/WebConfiguration.hbm.xml" />
<mapping resource="conf/hbm/WorkflowEventData.hbm.xml" />
<mapping resource="conf/hbm/WorkflowEventInstance.hbm.xml" />
<mapping resource="conf/hbm/WorkflowInstance.hbm.xml" />
<mapping resource="conf/hbm/Team.hbm.xml" />


Also, if you have set metadata-complete to "true" in your mapping files, there could be NamedQueries in annotations (but I don't think you mixed that).


If you still can't fix the problem, set the logging level of "org.hibernate.hql" to debug, to see what the antlr-parser, does.[/quote]

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 6:06 am 
Newbie

Joined: Thu Jan 22, 2009 1:12 am
Posts: 7
Location: India
Yes , but my local machine accessing only PhoneConfiguration.hbm.xml... Others came from sever while updating the SVN.So I'm having only one query which is access respective hbm file i.e PhoneConfiguration.hbm.xml.

Will you tell me how to configure hibernate for debug.As I'm not using log4j.xml,but using log4j.jar

_________________
Don't loose hope.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 6:22 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
I guess you are not running in a container, but a standalone application?
If so, you can create log4j.properties in the root-directory of your classpath, which looks like this:
Code:
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n


### set log levels - for more verbose logging change 'info' to 'debug' ###

log4j.rootLogger=warn, stdout

log4j.logger.org.hibernate=warn
#log4j.logger.org.hibernate=debug

### log HQL query parser activity
log4j.logger.org.hibernate.hql.ast.AST=all

### log just the SQL
#log4j.logger.org.hibernate.SQL=debug

### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=warn

### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=warn

### log HQL parse trees
log4j.logger.org.hibernate.hql=debug

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 7:02 am 
Newbie

Joined: Thu Jan 22, 2009 1:12 am
Posts: 7
Location: India
Ya thanks for the logger

I changed the query to

String hql_tst = "update phone_configuration set int_param_value='"
+ tracking_start_time
+ "' where param_name='TRACKING_START_TIME' and customer_id=2";

Query query_tst = session.createSQLQuery(hql_tst);
query_tst.executeUpdate();


which is working fine but is it the correct way to get answer?

_________________
Don't loose hope.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 7:48 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
What type is int_param_value? Is it really a String? If not, try to use the right setXXX-Method on your query. Are the other attributes also Strings?

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 23, 2009 12:00 am 
Newbie

Joined: Thu Jan 22, 2009 1:12 am
Posts: 7
Location: India
int_param_value having data type as integer , Ya I'll set it as integer. param_name is varchar and customer_id is integer .I want to know what is the fault with earlier query which use to give antlr exception.

_________________
Don't loose hope.


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