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.
|
|