-->
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.  [ 3 posts ] 
Author Message
 Post subject: Weird issue using Hibernate and MySQL innodb tables
PostPosted: Mon Jun 20, 2005 12:35 pm 
Newbie

Joined: Mon Jun 20, 2005 12:31 pm
Posts: 14
Hey everyone,

would love to know if anyone has any clue on what might be occuring.
Im using hibernate with innodb type tables in MySQL.

The data is being inserted into the database.
I can retrieve the data via hibernate no problem also.
However.. using ANY query analyzer i can not see the data in the actual database.

this is the log from my test app. showing the inserts

Code:

12:28:11,953  INFO Environment:483 - Hibernate 2.1.8
12:28:11,953  INFO Environment:517 - loaded properties from resource hibernate.properties: {hibernate.connection.username=element, hibernate.connection.password=password, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.show_sql=true, hibernate.connection.url=jdbc:mysql://localhost/element, hibernate.connection.driver_class=com.mysql.jdbc.Driver}
12:28:11,953  INFO Environment:543 - using CGLIB reflection optimizer
12:28:11,953  INFO Environment:572 - using JDK 1.4 java.sql.Timestamp handling
12:28:11,953  INFO Configuration:189 - Mapping file: C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\Element\bin\com\wirednorth\element\model\User.hbm.xml
12:28:12,328  INFO Binder:229 - Mapping class: com.wirednorth.element.model.User -> USERS
12:28:12,359  INFO Configuration:641 - processing one-to-many association mappings
12:28:12,359  INFO Configuration:650 - processing one-to-one association property references
12:28:12,375  INFO Configuration:675 - processing foreign key constraints
12:28:12,391  INFO Dialect:86 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
12:28:12,391  INFO SettingsFactory:70 - Maximim outer join fetch depth: 2
12:28:12,391  INFO SettingsFactory:74 - Use outer join fetching: true
12:28:12,391  INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
12:28:12,391  INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 20
12:28:12,406  INFO DriverManagerConnectionProvider:77 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/element
12:28:12,406  INFO DriverManagerConnectionProvider:78 - connection properties: {user=element, password=password}
12:28:12,406  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
12:28:12,953  INFO SettingsFactory:114 - Use scrollable result sets: true
12:28:12,953  INFO SettingsFactory:117 - Use JDBC3 getGeneratedKeys(): true
12:28:12,953  INFO SettingsFactory:120 - Optimize cache for minimal puts: false
12:28:12,953  INFO SettingsFactory:126 - echoing all SQL to stdout
12:28:12,953  INFO SettingsFactory:129 - Query language substitutions: {}
12:28:12,953  INFO SettingsFactory:140 - cache provider: net.sf.hibernate.cache.EhCacheProvider
12:28:12,953  INFO Configuration:1130 - instantiating and configuring caches
12:28:12,969  WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Documents%20and%20Settings/JMGuillemette/My%20Documents/personal/projects/Element/code/ehcache/ehcache-1.1.jar!/ehcache-failsafe.xml
12:28:13,062  INFO SessionFactoryImpl:119 - building session factory
12:28:13,297  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
Hibernate: insert into USERS (USERNAME, PASSWORD) values (?, ?)
12:28:13,422 DEBUG StringType:46 - binding 'jamie' to parameter: 1
12:28:13,422 DEBUG StringType:46 - binding '1234' to parameter: 2
com.wirednorth.element.model.User@4a0ff2bb[id=6]
Hibernate: select user0_.ID as ID0_, user0_.USERNAME as USERNAME0_, user0_.PASSWORD as PASSWORD0_ from USERS user0_ where user0_.ID=?
12:28:13,469 DEBUG IntegerType:46 - binding '6' to parameter: 1
12:28:13,469 DEBUG StringType:68 - returning 'jamie' as column: USERNAME0_
12:28:13,469 DEBUG StringType:68 - returning '1234' as column: PASSWORD0_
com.wirednorth.element.model.User@474772bb[id=6]
Hibernate: select user0_.ID as ID0_, user0_.USERNAME as USERNAME0_, user0_.PASSWORD as PASSWORD0_ from USERS user0_ where user0_.ID=?
12:28:13,484 DEBUG IntegerType:46 - binding '6' to parameter: 1
12:28:13,484 DEBUG StringType:68 - returning 'jamie' as column: USERNAME0_
12:28:13,484 DEBUG StringType:68 - returning '1234' as column: PASSWORD0_
com.wirednorth.element.model.User@4c8cf2b9[id=6]



Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 20, 2005 1:07 pm 
Newbie

Joined: Mon Jun 20, 2005 12:31 pm
Posts: 14
observation :

-if i just use session.flush();
the data is not stored to the db

-if i do a session.beginTransaciton() and txn.comit();
it is saved to db?


Why would i have to use transactions?
isnt flush() good enough if i have not explicitly done a session.beginTransaction() ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 20, 2005 2:49 pm 
Newbie

Joined: Mon Jun 20, 2005 12:31 pm
Posts: 14
Code:

import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.Transaction;
import net.sf.hibernate.cfg.Configuration;

import com.wirednorth.element.model.User;

/*
* Created on Jun 18, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/

/**
* @author JMGuillemette
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class HibernateTest {

   public static void main(String[] args)throws Exception{
      User user = new User();
      user.setUsername("tstUserName");
      user.setPassword("tstPassword");
      Configuration config = new Configuration();
      config.addClass(User.class);
      SessionFactory factory = config.buildSessionFactory();
      Session session = factory.openSession();
      session.save(user);
      session.flush();
      
      
   }
   
}



the output:

Code:

14:46:55,219  INFO Environment:483 - Hibernate 2.1.8
14:46:55,234  INFO Environment:517 - loaded properties from resource hibernate.properties: {hibernate.connection.username=element, hibernate.connection.password=password, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.show_sql=true, hibernate.connection.url=jdbc:mysql://localhost/element, hibernate.connection.driver_class=com.mysql.jdbc.Driver}
14:46:55,234  INFO Environment:543 - using CGLIB reflection optimizer
14:46:55,234  INFO Environment:572 - using JDK 1.4 java.sql.Timestamp handling
14:46:55,234  INFO Configuration:351 - Mapping resource: com/wirednorth/element/model/User.hbm.xml
14:46:55,531  INFO Binder:229 - Mapping class: com.wirednorth.element.model.User -> USERS
14:46:55,562  INFO Configuration:641 - processing one-to-many association mappings
14:46:55,562  INFO Configuration:650 - processing one-to-one association property references
14:46:55,562  INFO Configuration:675 - processing foreign key constraints
14:46:55,578  INFO Dialect:86 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
14:46:55,594  INFO SettingsFactory:70 - Maximim outer join fetch depth: 2
14:46:55,594  INFO SettingsFactory:74 - Use outer join fetching: true
14:46:55,594  INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
14:46:55,594  INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 20
14:46:55,703  INFO DriverManagerConnectionProvider:77 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/element
14:46:55,703  INFO DriverManagerConnectionProvider:78 - connection properties: {user=element, password=password}
14:46:55,703  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
14:46:56,234  INFO SettingsFactory:114 - Use scrollable result sets: true
14:46:56,234  INFO SettingsFactory:117 - Use JDBC3 getGeneratedKeys(): true
14:46:56,234  INFO SettingsFactory:120 - Optimize cache for minimal puts: false
14:46:56,234  INFO SettingsFactory:126 - echoing all SQL to stdout
14:46:56,234  INFO SettingsFactory:129 - Query language substitutions: {}
14:46:56,234  INFO SettingsFactory:140 - cache provider: net.sf.hibernate.cache.EhCacheProvider
14:46:56,234  INFO Configuration:1130 - instantiating and configuring caches
14:46:56,250  WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Documents%20and%20Settings/JMGuillemette/My%20Documents/personal/projects/Element/code/ehcache/ehcache-1.1.jar!/ehcache-failsafe.xml
14:46:56,359  INFO SessionFactoryImpl:119 - building session factory
14:46:56,578  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
Hibernate: insert into USERS (USERNAME, PASSWORD) values (?, ?)
14:46:56,609 DEBUG StringType:46 - binding 'tstUserName' to parameter: 1
14:46:56,609 DEBUG StringType:46 - binding 'tstPassword' to parameter: 2



so everything looks good right? but run a manual query on the db.. and no data is there?! im really lost plz help.


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