-->
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.  [ 23 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Please help, data not saving in db
PostPosted: Tue Jun 21, 2005 10:36 am 
Newbie

Joined: Mon Jun 20, 2005 12:31 pm
Posts: 14
the prob im having is the everything seems to work fine.. but no data is actually store in the database.

my config
Code:
hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost/element
hibernate.connection.username=element
hibernate.connection.password=password
hibernate.show_sql=true
hibernate.autocommit=true


my code
Code:
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;

import com.wirednorth.element.model.User;

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();
      Integer i = (Integer)session.save(user);
      session.flush();
      User loaded = (User)session.load(User.class, i);
      System.out.println(loaded.toString());
   }
   
}


my tables are all Innodb!

the log is as follows

Code:
10:32:10,734  INFO Environment:483 - Hibernate 2.1.8
10:32:10,734  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, hibernate.autocommit=true}
10:32:10,734  INFO Environment:543 - using CGLIB reflection optimizer
10:32:10,734  INFO Environment:572 - using JDK 1.4 java.sql.Timestamp handling
10:32:10,734  INFO Configuration:351 - Mapping resource: com/wirednorth/element/model/User.hbm.xml
10:32:11,125  INFO Binder:229 - Mapping class: com.wirednorth.element.model.User -> USERS
10:32:11,156  INFO Configuration:641 - processing one-to-many association mappings
10:32:11,156  INFO Configuration:650 - processing one-to-one association property references
10:32:11,156  INFO Configuration:675 - processing foreign key constraints
10:32:11,172  INFO Dialect:86 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
10:32:11,188  INFO SettingsFactory:70 - Maximim outer join fetch depth: 2
10:32:11,188  INFO SettingsFactory:74 - Use outer join fetching: true
10:32:11,188  INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
10:32:11,188  INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 20
10:32:11,312  INFO DriverManagerConnectionProvider:77 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/element
10:32:11,312  INFO DriverManagerConnectionProvider:78 - connection properties: {user=element, password=password}
10:32:11,328  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
10:32:11,953  INFO SettingsFactory:114 - Use scrollable result sets: true
10:32:11,953  INFO SettingsFactory:117 - Use JDBC3 getGeneratedKeys(): true
10:32:11,953  INFO SettingsFactory:120 - Optimize cache for minimal puts: false
10:32:11,953  INFO SettingsFactory:126 - echoing all SQL to stdout
10:32:11,953  INFO SettingsFactory:129 - Query language substitutions: {}
10:32:11,953  INFO SettingsFactory:140 - cache provider: net.sf.hibernate.cache.EhCacheProvider
10:32:11,953  INFO Configuration:1130 - instantiating and configuring caches
10:32:11,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
10:32:12,219  INFO SessionFactoryImpl:119 - building session factory
10:32:12,531  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
Hibernate: insert into USERS (USERNAME, PASSWORD) values (?, ?)
10:32:12,625 DEBUG StringType:46 - binding 'tstUserName' to parameter: 1
10:32:12,625 DEBUG StringType:46 - binding 'tstPassword' to parameter: 2
com.wirednorth.element.model.User@1a5915e6[id=1]



what happens if if run SELECT * FROM USER; i get 0 rows returned. :(


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 5:28 pm 
Beginner
Beginner

Joined: Sun Aug 22, 2004 5:32 pm
Posts: 40
I am having the exact same issue, but with Oracle instead of MySQL.

_________________
Scott
www.HikeHaven.com


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 10:20 pm 
Regular
Regular

Joined: Thu Apr 21, 2005 9:05 am
Posts: 50
Location: Boston, U.S
try removing setAutoCommit attribute from hibernate configuration file.

following is the default configuration in hibernate.properties files
# enable JDBC autocommit (not recommended!)
#hibernate.connection.autocommit true.

Hibernate does not recommend the usage of setAutoCommit(true),
so dont do it.

The other option is to use transaction commit instead of flush
tx = session.beginTransaction();
--
--
tx.commit;

Hope it helps.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 22, 2005 2:22 am 
Newbie

Joined: Mon Jun 20, 2005 6:20 am
Posts: 7
Hi,

I'm not sure but I would try to close the session (session.close()) in the end of the main method


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 22, 2005 2:34 pm 
Beginner
Beginner

Joined: Sun Aug 22, 2004 5:32 pm
Posts: 40
Enable the show_sql property in the hibernate.cfg.xml to determine that the correct query is going to the database. This was enough for me to recognize the wrong query was being sent.

_________________
Scott
www.HikeHaven.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2005 12:38 am 
Newbie

Joined: Mon Jun 20, 2005 12:31 pm
Posts: 14
i have show_sql on..
see log i originally pasted

closing the session doesnt appear to fix anything:(


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2005 9:03 am 
Newbie

Joined: Mon Jun 20, 2005 12:31 pm
Posts: 14
ok.. i turned up the logging and now we see the following.
Notice it admits in the log thats is not saving any data to the db..
im sure ive done / setup something wrong.. im just not sure what

Code:
09:01:51,484  INFO Environment:483 - Hibernate 2.1.8
09:01:51,484  INFO Environment:517 - loaded properties from resource hibernate.properties: {hibernate.connection.username=sa, hibernate.connection.password=, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect, hibernate.show_sql=true, hibernate.connection.url=jdbc:hsqldb:file:element, hibernate.connection.driver_class=org.hsqldb.jdbcDriver}
09:01:51,484  INFO Environment:543 - using CGLIB reflection optimizer
09:01:51,484  INFO Environment:572 - using JDK 1.4 java.sql.Timestamp handling
09:01:51,484  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
09:01:51,641 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
09:01:51,641 DEBUG DTDEntityResolver:32 - found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
09:01:51,828  INFO Binder:229 - Mapping class: com.wirednorth.element.model.User -> USERS
09:01:51,859 DEBUG Binder:486 - Mapped property: id -> ID, type: integer
09:01:51,875 DEBUG Binder:486 - Mapped property: username -> USERNAME, type: string
09:01:51,875 DEBUG Binder:486 - Mapped property: password -> PASSWORD, type: string
09:01:51,875 DEBUG Binder:1280 - Named query: findByUserName ->
      from com.wirednorth.model.User as user where user.username = :userName
   
09:01:51,875  INFO Configuration:641 - processing one-to-many association mappings
09:01:51,875  INFO Configuration:650 - processing one-to-one association property references
09:01:51,875  INFO Configuration:675 - processing foreign key constraints
09:01:51,891  INFO Dialect:86 - Using dialect: net.sf.hibernate.dialect.HSQLDialect
09:01:51,891 DEBUG SQLExceptionConverterFactory:49 - Using dialect defined converter
09:01:52,031  INFO SettingsFactory:74 - Use outer join fetching: true
09:01:52,047  INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
09:01:52,047  INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 20
09:01:52,047  INFO DriverManagerConnectionProvider:77 - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:file:element
09:01:52,047  INFO DriverManagerConnectionProvider:78 - connection properties: {user=sa, password=}
09:01:52,047  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
09:01:52,047 DEBUG DriverManagerConnectionProvider:84 - total checked-out connections: 0
09:01:52,062 DEBUG DriverManagerConnectionProvider:100 - opening new JDBC connection
09:01:52,375 DEBUG DriverManagerConnectionProvider:106 - created connection to: jdbc:hsqldb:file:element, Isolation Level: 1
09:01:52,375 DEBUG DriverManagerConnectionProvider:120 - returning connection to pool, pool size: 1
09:01:52,375  INFO SettingsFactory:114 - Use scrollable result sets: true
09:01:52,375  INFO SettingsFactory:117 - Use JDBC3 getGeneratedKeys(): false
09:01:52,375  INFO SettingsFactory:120 - Optimize cache for minimal puts: false
09:01:52,406  INFO SettingsFactory:126 - echoing all SQL to stdout
09:01:52,406  INFO SettingsFactory:129 - Query language substitutions: {}
09:01:52,406  INFO SettingsFactory:140 - cache provider: net.sf.hibernate.cache.EhCacheProvider
09:01:52,422 DEBUG SettingsFactory:173 - Wrap result sets enabled? : false
09:01:52,422  INFO Configuration:1130 - instantiating and configuring caches
09:01:52,422  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
09:01:52,531  INFO SessionFactoryImpl:119 - building session factory
09:01:52,531 DEBUG SessionFactoryImpl:125 - instantiating session factory with properties: {java.assistive=ON, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, hibernate.connection.password=, sun.boot.library.path=C:\java\IBM\Rational\SDP\6.0\eclipse\jre\bin, java.vm.version=1.4.2, hibernate.connection.username=sa, java.vm.vendor=IBM Corporation, java.vendor.url=http://www.ibm.com/, path.separator=;, java.vm.name=Classic VM, file.encoding.pkg=sun.io, user.country=US, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\Element, java.runtime.version=1.4.2, java.fullversion=J2RE 1.4.2 IBM Windows 32 build cn142-20040926 (JIT enabled: jitc), java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\endorsed, os.arch=x86, com.ibm.vm.bitmode=32, java.io.tmpdir=C:\DOCUME~1\JMGUIL~1\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, java.awt.fonts=, os.name=Windows XP, sun.java2d.fontpath=, java.library.path=C:\java\IBM\Rational\SDP\6.0\eclipse\jre\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;c;\java\ant\bin;C:\Program Files\MySQL\MySQL Server 4.1\bin, java.specification.name=Java Platform API Specification, java.class.version=48.0, ibm.system.encoding=Cp1252, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, invokedviajava=, os.version=5.1, user.home=C:\Documents and Settings\JMGuillemette, user.timezone=America/New_York, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.4, hibernate.connection.driver_class=org.hsqldb.jdbcDriver, java.class.path=/c:/java/IBM/Rational/SDP/6.0/eclipse/plugins/org.eclipse.jdt.junit_3.0.1/junitsupport.jar;/c:/java/IBM/Rational/SDP/6.0/eclipse/plugins/org.eclipse.jdt.junit.runtime_3.0.0/junitruntime.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\Element\bin;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\hibernate\hibernate2.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\hibernate\hibernate-tools.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\hibernate\odmg.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jakarta-commons\commons-attributes-api.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jakarta-commons\commons-attributes-compiler.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jakarta-commons\commons-beanutils.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jakarta-commons\commons-codec.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jakarta-commons\commons-collections.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jakarta-commons\commons-dbcp.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jakarta-commons\commons-digester.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jakarta-commons\commons-discovery.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jakarta-commons\commons-fileupload.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jakarta-commons\commons-httpclient.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jakarta-commons\commons-lang.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jakarta-commons\commons-logging.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jakarta-commons\commons-pool.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jakarta-commons\commons-validator.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\junit\junit.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\log4j\log4j-1.2.9.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\mysql\mysql-connector-java-3.1.7-bin.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\xml\jdom.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\xml\xalan-2.4.0.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\xml\xerces-2.4.0.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\xml\xml-apis.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\spring\spring.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\spring\spring-aop.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\spring\spring-context.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\spring\spring-core.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\spring\spring-dao.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\spring\spring-mock.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\spring\spring-orm.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\spring\spring-web.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\spring\spring-webmvc.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\cglib\cglib-nodep-2.1-dev.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\dom4j\dom4j.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\ehcache\ehcache-1.1.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\jta\jta.jar;C:\Documents and Settings\JMGuillemette\My Documents\personal\projects\Element\code\hsqldb\hsqldb.jar, user.name=JMGuillemette, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\java\IBM\Rational\SDP\6.0\eclipse\jre, sun.arch.data.model=32, hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect, hibernate.connection.url=jdbc:hsqldb:file:element, user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=J2RE 1.4.2 IBM Windows 32 build cn142-20040926 (JIT enabled: jitc), java.version=1.4.2, java.ext.dirs=C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\ext, sun.boot.class.path=C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\core.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\graphics.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\security.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\server.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\xml.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\charsets.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\ibmcertpathprovider.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\ibmjaasactivelm.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\ibmjaaslm.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\ibmjcefw.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\ibmjgssprovider.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\ibmjssefips.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\ibmjsseprovider.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\ibmorb.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\ibmorbapi.jar;C:\java\IBM\Rational\SDP\6.0\eclipse\jre\lib\ibmpkcs.jar, java.vendor=IBM Corporation, file.separator=\, java.vendor.url.bug=, java.compiler=jitc, sun.io.unicode.encoding=UnicodeLittle, hibernate.properties=}
09:01:52,766 DEBUG SessionFactoryObjectFactory:39 - initializing class SessionFactoryObjectFactory
09:01:52,766 DEBUG SessionFactoryObjectFactory:76 - registered: 40288d7f04a94a3f0104a94a40fe0000 (unnamed)
09:01:52,766  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
09:01:52,766 DEBUG SessionFactoryImpl:196 - instantiated session factory
09:01:52,844 DEBUG SessionImpl:560 - opened session
09:01:52,922 DEBUG SessionImpl:836 - saving [com.wirednorth.element.model.User#<null>]
09:01:52,922 DEBUG SessionImpl:2330 - executing insertions
09:01:52,938 DEBUG EntityPersister:484 - Inserting entity: com.wirednorth.element.model.User (native id)
09:01:52,953 DEBUG BatcherImpl:204 - about to open: 0 open PreparedStatements, 0 open ResultSets
09:01:52,953 DEBUG DriverManagerConnectionProvider:84 - total checked-out connections: 0
09:01:52,969 DEBUG DriverManagerConnectionProvider:90 - using pooled JDBC connection, pool size: 0
09:01:52,984 DEBUG SQL:230 - insert into USERS (USERNAME, PASSWORD, ID) values (?, ?, null)
Hibernate: insert into USERS (USERNAME, PASSWORD, ID) values (?, ?, null)
09:01:52,984 DEBUG BatcherImpl:253 - preparing statement
09:01:53,000 DEBUG EntityPersister:382 - Dehydrating entity: [com.wirednorth.element.model.User#<null>]
09:01:53,000 DEBUG StringType:46 - binding 'jamie' to parameter: 1
09:01:53,000 DEBUG StringType:46 - binding '1234' to parameter: 2
09:01:53,000 DEBUG BatcherImpl:211 - done closing: 0 open PreparedStatements, 0 open ResultSets
09:01:53,000 DEBUG BatcherImpl:275 - closing statement
09:01:53,000 DEBUG BatcherImpl:204 - about to open: 0 open PreparedStatements, 0 open ResultSets
09:01:53,000 DEBUG SQL:230 - call identity()
Hibernate: call identity()
09:01:53,016 DEBUG BatcherImpl:253 - preparing statement
09:01:53,016 DEBUG AbstractEntityPersister:1234 - Natively generated identity: 5
09:01:53,016 DEBUG BatcherImpl:211 - done closing: 0 open PreparedStatements, 0 open ResultSets
09:01:53,016 DEBUG BatcherImpl:275 - closing statement
09:01:53,016 DEBUG SessionImpl:2267 - flushing session
09:01:53,031 DEBUG SessionImpl:2467 - Flushing entities and processing referenced collections
09:01:53,031 DEBUG SessionImpl:2808 - Processing unreferenced collections
09:01:53,031 DEBUG SessionImpl:2822 - Scheduling collection removes/(re)creates/updates
09:01:53,031 DEBUG SessionImpl:2291 - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
09:01:53,031 DEBUG SessionImpl:2296 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
09:01:53,031 DEBUG Printer:75 - listing entities:
09:01:53,031 DEBUG Printer:82 - com.wirednorth.element.model.User{password=1234, username=jamie, id=5}
09:01:53,031 DEBUG SessionImpl:2380 - executing flush
09:01:53,031 DEBUG SessionImpl:2852 - post flush
09:01:53,031 DEBUG SessionImpl:578 - closing session
09:01:53,031 DEBUG SessionImpl:3383 - disconnecting session
09:01:53,031 DEBUG DriverManagerConnectionProvider:120 - returning connection to pool, pool size: 1
09:01:53,031 DEBUG SessionImpl:596 - transaction completion
com.wirednorth.element.model.User@6f0cdcca[id=5]
09:01:53,047 DEBUG SessionImpl:560 - opened session
09:01:53,047 DEBUG SessionImpl:1996 - loading [com.wirednorth.element.model.User#5]
09:01:53,047 DEBUG SessionImpl:2094 - attempting to resolve [com.wirednorth.element.model.User#5]
09:01:53,047 DEBUG SessionImpl:2130 - object not resolved in any cache [com.wirednorth.element.model.User#5]
09:01:53,047 DEBUG EntityPersister:410 - Materializing entity: [com.wirednorth.element.model.User#5]
09:01:53,047 DEBUG BatcherImpl:204 - about to open: 0 open PreparedStatements, 0 open ResultSets
09:01:53,047 DEBUG DriverManagerConnectionProvider:84 - total checked-out connections: 0
09:01:53,047 DEBUG DriverManagerConnectionProvider:90 - using pooled JDBC connection, pool size: 0
09:01:53,047 DEBUG SQL:230 - select user0_.ID as ID0_, user0_.USERNAME as USERNAME0_, user0_.PASSWORD as PASSWORD0_ from USERS user0_ where user0_.ID=?
Hibernate: select user0_.ID as ID0_, user0_.USERNAME as USERNAME0_, user0_.PASSWORD as PASSWORD0_ from USERS user0_ where user0_.ID=?
09:01:53,078 DEBUG BatcherImpl:253 - preparing statement
09:01:53,188 DEBUG IntegerType:46 - binding '5' to parameter: 1
09:01:53,188 DEBUG SessionImpl:3435 - running Session.finalize()
09:01:53,188 DEBUG Loader:281 - processing result set
09:01:53,188 DEBUG Loader:484 - result row: 5
09:01:53,188 DEBUG Loader:615 - Initializing object from ResultSet: 5
09:01:53,188 DEBUG Loader:684 - Hydrating entity: com.wirednorth.element.model.User#5
09:01:53,188 DEBUG StringType:68 - returning 'jamie' as column: USERNAME0_
09:01:53,188 DEBUG StringType:68 - returning '1234' as column: PASSWORD0_
09:01:53,188 DEBUG Loader:298 - done processing result set (1 rows)
09:01:53,188 DEBUG BatcherImpl:211 - done closing: 0 open PreparedStatements, 0 open ResultSets
09:01:53,188 DEBUG BatcherImpl:275 - closing statement
09:01:53,203 DEBUG Loader:318 - total objects hydrated: 1
09:01:53,203 DEBUG SessionImpl:2216 - resolving associations for [com.wirednorth.element.model.User#5]
09:01:53,203 DEBUG SessionImpl:2247 - done materializing entity [com.wirednorth.element.model.User#5]
09:01:53,203 DEBUG SessionImpl:3161 - initializing non-lazy collections
09:01:53,203 DEBUG SessionImpl:2267 - flushing session
09:01:53,203 DEBUG SessionImpl:2467 - Flushing entities and processing referenced collections
09:01:53,203 DEBUG SessionImpl:2808 - Processing unreferenced collections
09:01:53,203 DEBUG SessionImpl:2822 - Scheduling collection removes/(re)creates/updates
09:01:53,203 DEBUG SessionImpl:2291 - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
09:01:53,203 DEBUG SessionImpl:2296 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
09:01:53,203 DEBUG Printer:75 - listing entities:
09:01:53,203 DEBUG Printer:82 - com.wirednorth.element.model.User{password=1234, username=jamie, id=5}
09:01:53,203 DEBUG SessionImpl:2380 - executing flush
09:01:53,203 DEBUG SessionImpl:2852 - post flush
09:01:53,203 DEBUG SessionImpl:578 - closing session
09:01:53,203 DEBUG SessionImpl:3383 - disconnecting session
09:01:53,203 DEBUG DriverManagerConnectionProvider:120 - returning connection to pool, pool size: 1
09:01:53,203 DEBUG SessionImpl:596 - transaction completion
09:01:53,328 DEBUG SessionImpl:560 - opened session
09:01:53,328 DEBUG SessionImpl:1996 - loading [com.wirednorth.element.model.User#5]
09:01:53,328 DEBUG SessionImpl:2094 - attempting to resolve [com.wirednorth.element.model.User#5]
09:01:53,328 DEBUG SessionImpl:2130 - object not resolved in any cache [com.wirednorth.element.model.User#5]
09:01:53,328 DEBUG EntityPersister:410 - Materializing entity: [com.wirednorth.element.model.User#5]
09:01:53,328 DEBUG BatcherImpl:204 - about to open: 0 open PreparedStatements, 0 open ResultSets
09:01:53,344 DEBUG SessionImpl:3435 - running Session.finalize()
09:01:53,344 DEBUG DriverManagerConnectionProvider:84 - total checked-out connections: 0
09:01:53,344 DEBUG DriverManagerConnectionProvider:90 - using pooled JDBC connection, pool size: 0
09:01:53,344 DEBUG SQL:230 - select user0_.ID as ID0_, user0_.USERNAME as USERNAME0_, user0_.PASSWORD as PASSWORD0_ from USERS user0_ where user0_.ID=?
Hibernate: select user0_.ID as ID0_, user0_.USERNAME as USERNAME0_, user0_.PASSWORD as PASSWORD0_ from USERS user0_ where user0_.ID=?
09:01:53,344 DEBUG BatcherImpl:253 - preparing statement
09:01:53,344 DEBUG IntegerType:46 - binding '5' to parameter: 1
09:01:53,344 DEBUG Loader:281 - processing result set
09:01:53,344 DEBUG Loader:484 - result row: 5
09:01:53,344 DEBUG Loader:615 - Initializing object from ResultSet: 5
09:01:53,344 DEBUG Loader:684 - Hydrating entity: com.wirednorth.element.model.User#5
09:01:53,344 DEBUG StringType:68 - returning 'jamie' as column: USERNAME0_
09:01:53,344 DEBUG StringType:68 - returning '1234' as column: PASSWORD0_
09:01:53,344 DEBUG Loader:298 - done processing result set (1 rows)
09:01:53,344 DEBUG BatcherImpl:211 - done closing: 0 open PreparedStatements, 0 open ResultSets
09:01:53,344 DEBUG BatcherImpl:275 - closing statement
09:01:53,344 DEBUG Loader:318 - total objects hydrated: 1
09:01:53,344 DEBUG SessionImpl:2216 - resolving associations for [com.wirednorth.element.model.User#5]
09:01:53,344 DEBUG SessionImpl:2247 - done materializing entity [com.wirednorth.element.model.User#5]
09:01:53,344 DEBUG SessionImpl:3161 - initializing non-lazy collections
09:01:53,344 DEBUG SessionImpl:2267 - flushing session
09:01:53,344 DEBUG SessionImpl:2467 - Flushing entities and processing referenced collections
09:01:53,344 DEBUG SessionImpl:2808 - Processing unreferenced collections
09:01:53,344 DEBUG SessionImpl:2822 - Scheduling collection removes/(re)creates/updates
09:01:53,344 DEBUG SessionImpl:2291 - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
09:01:53,344 DEBUG SessionImpl:2296 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
09:01:53,344 DEBUG Printer:75 - listing entities:
09:01:53,344 DEBUG Printer:82 - com.wirednorth.element.model.User{password=1234, username=jamie, id=5}
09:01:53,344 DEBUG SessionImpl:2380 - executing flush
09:01:53,344 DEBUG SessionImpl:2852 - post flush
09:01:53,344 DEBUG SessionImpl:578 - closing session
09:01:53,344 DEBUG SessionImpl:3383 - disconnecting session
09:01:53,344 DEBUG DriverManagerConnectionProvider:120 - returning connection to pool, pool size: 1
09:01:53,344 DEBUG SessionImpl:596 - transaction completion



Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2005 9:25 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Instead of wild guessing you guys could just read up on transactions in the reference documentation. Even the first tutorial tells you how to do this correctly.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2005 10:51 am 
Newbie

Joined: Mon Jun 20, 2005 12:31 pm
Posts: 14
i thank you for your comment. But this code is not using transactions.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2005 10:59 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Yeah, and you don't think that this is possibly the problem?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2005 11:03 am 
Newbie

Joined: Mon Jun 20, 2005 12:31 pm
Posts: 14
perhaps im a bit confused. I thought transactions where optional ?

all im doing is getting a session object
creating an new instance of a persistant class ( User )
and then saving the instance
and calling flush()

its a very very basic set of steps..


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2005 11:06 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
So you haven't read any documentation, not even the beginners tutorial, much less "Working with objects" or anything else from the reference?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2005 11:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Where did you get the strange notion that transactions are optional when working with a relational database? Are you getting confused by JDBC "autocommit" mode? (Meaning a transaction for each statement.) And where in the Hibernate documentation did you find examples where no transactions were used, or a statement that transactions were "optional"?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2005 11:07 am 
Beginner
Beginner

Joined: Mon Jan 24, 2005 6:42 pm
Posts: 26
all im doing is getting a session object
session.beginTransaction()creating an new instance of a persistant class ( User )
and then saving the instance
session.commitTransaction()
session.close()


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2005 11:09 am 
Newbie

Joined: Mon Jun 20, 2005 12:31 pm
Posts: 14
actually i have both the Hibernate : a developers notebook and Hibernate in action books right next to me.. and both imply that the transaction framework is not manditory.

No offence.. but if there is something ive miss interpreted and you know please feel free to correct me.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 23 posts ]  Go to page 1, 2  Next

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.