Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- i can't insert to database
- 16 mai 2011 17:21:39 net.sf.hibernate.cfg.Environment <clinit>
- INFO: Hibernate 2.1.6
- 16 mai 2011 17:21:39 net.sf.hibernate.cfg.Environment <clinit>
- INFO: hibernate.properties not found
- 16 mai 2011 17:21:39 net.sf.hibernate.cfg.Environment <clinit>
- INFO: using CGLIB reflection optimizer
- 16 mai 2011 17:21:39 net.sf.hibernate.cfg.Configuration configure
- INFO: configuring from resource: /hibernate/hibernate.cfg.xml
- 16 mai 2011 17:21:39 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
- INFO: Configuration resource: /hibernate/hibernate.cfg.xml
- 16 mai 2011 17:21:40 net.sf.hibernate.cfg.Configuration addResource
- INFO: Mapping resource: hibernate/Timesheet.hbm.xml
- 16 mai 2011 17:21:40 net.sf.hibernate.cfg.Binder bindRootClass
- INFO: Mapping class: hibernate.Timesheet -> timesheet
- 16 mai 2011 17:21:40 net.sf.hibernate.cfg.Configuration doConfigure
- INFO: Configured SessionFactory: null
- 16 mai 2011 17:21:40 net.sf.hibernate.cfg.Configuration secondPassCompile
- INFO: processing one-to-many association mappings
- 16 mai 2011 17:21:40 net.sf.hibernate.cfg.Configuration secondPassCompile
- INFO: processing one-to-one association property references
- 16 mai 2011 17:21:40 net.sf.hibernate.cfg.Configuration secondPassCompile
- INFO: processing foreign key constraints
- 16 mai 2011 17:21:40 net.sf.hibernate.dialect.Dialect <init>
- INFO: Using dialect: net.sf.hibernate.dialect.MySQLDialect
- 16 mai 2011 17:21:40 net.sf.hibernate.cfg.SettingsFactory buildSettings
- INFO: Maximim outer join fetch depth: 2
- 16 mai 2011 17:21:40 net.sf.hibernate.cfg.SettingsFactory buildSettings
- INFO: Use outer join fetching: true
- 16 mai 2011 17:21:40 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
- INFO: Using Hibernate built-in connection pool (not for production use!)
- 16 mai 2011 17:21:40 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
- INFO: Hibernate connection pool size: 20
- 16 mai 2011 17:21:40 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
- INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3306/timesheet
- 16 mai 2011 17:21:40 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
- INFO: connection properties: {user=root, password=manel}
- 16 mai 2011 17:21:40 net.sf.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
- INFO: Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
- 16 mai 2011 17:21:40 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
- INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
- 16 mai 2011 17:21:40 net.sf.hibernate.cfg.SettingsFactory buildSettings
- INFO: Use scrollable result sets: true
- 16 mai 2011 17:21:40 net.sf.hibernate.cfg.SettingsFactory buildSettings
- INFO: Use JDBC3 getGeneratedKeys(): true
- 16 mai 2011 17:21:40 net.sf.hibernate.cfg.SettingsFactory buildSettings
- INFO: Optimize cache for minimal puts: false
- 16 mai 2011 17:21:40 net.sf.hibernate.cfg.SettingsFactory buildSettings
- INFO: Query language substitutions: {}
- 16 mai 2011 17:21:40 net.sf.hibernate.cfg.SettingsFactory buildSettings
- INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
- 16 mai 2011 17:21:40 net.sf.hibernate.cfg.Configuration configureCaches
- INFO: instantiating and configuring caches
- 16 mai 2011 17:21:40 net.sf.hibernate.impl.SessionFactoryImpl <init>
- INFO: building session factory
- 16 mai 2011 17:21:40 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
- INFO: Not binding factory to JNDI, no JNDI name configured
- <!-- local connection properties -->
- <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/timesheet</property>
- <property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
- <property name="hibernate.connection.username">root</property>
- <property name="hibernate.connection.password">manel</property>
- <!-- property name="hibernate.connection.pool_size"></property -->
- <!-- dialect for MySQL -->
- <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
- <property name="hibernate.show_sql">false</property>
- <property name="hibernate.use_outer_join">true</property>
- <property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
- <mapping resource="hibernate/Timesheet.hbm.xml"/>
- </session-factory>
- try {
- Timesheet time = new Timesheet();
- Session session = SessionHibernate.getSession();
- time.setAction(action);
- time.setDate(date);
- time.setHeure(heure);
- time.setId(id);
- net.sf.hibernate.Transaction tx = session.beginTransaction();
- getSession().save(time);
- getSession().flush();
- tx.commit();
- } catch (HibernateException e) {
- } finally {
- try {
- SessionHibernate.closeSession();
- } catch (HibernateException e1) {
- e1.printStackTrace();
- }
- }
- private static String CONFIG_FILE_LOCATION = "/hibernate/hibernate.cfg.xml";
- private static final ThreadLocal threadLocal = new ThreadLocal();
- private static net.sf.hibernate.cfg.Configuration configuration = new Configuration();
- private static net.sf.hibernate.SessionFactory sessionFactory;
- private static String configFile = CONFIG_FILE_LOCATION;
- public SessionHibernate() {
- }
- @SuppressWarnings("unchecked")
- public static Session getSession() throws HibernateException {
- Session session = (Session) threadLocal.get();
- if (session == null || !session.isOpen()) {
- if (sessionFactory == null) {
- rebuildSessionFactory();
- }
- session = (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
- * @throws net.sf.hibernate.HibernateException
- */
- @SuppressWarnings("unchecked")
- public static void closeSession() throws HibernateException, net.sf.hibernate.HibernateException {
- Session session = (Session) threadLocal.get();
- threadLocal.set(null);
- if (session != null) {
- session.close();
- }
- }
- /**
- * return session factory
- *
- */
- public static net.sf.hibernate.SessionFactory getSessionFactory() {
- return sessionFactory;
- }
- /**
- * return session factory
- *
- * session factory will be rebuilded in the next call
- */
- public static void setConfigFile(String configFile) {
- SessionHibernate.configFile = configFile;
- sessionFactory = null;
- }
- /**
- * return hibernate configuration
- *
- */
- public static Configuration getConfiguration() {
- return configuration;
- }
Add Comment
Please, Sign In to add comment