• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

run without errors, but data not inserted in database

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am trying with a sample application for learning hibernate.

I am using hibernate 3 with MySQL database. I want to save a sample object-Event-(which has only 2 properties 'id' and 'name') to the database. But when i run my application with the following lines of code it run with out any errors, But the data not saved in the database.

Configuration cfg=new Configuration();
SessionFactory factory = cfg.configure().buildSessionFactory();
Session session = factory.openSession();
Event testevent = new Event();
testevent.setName("ABCD");
session.save(testevent);
session.flush();
session.close();

I tried to analyse the log. But upto my knowledge i could nt figureout the issue. Because of that, to analyse my problem in detail, I am attaching the stacktrace also.

----------------------------------------------------------------
[echo] If you see this, it compiled
build:
[java] 0 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.2.2
[java] 30 [main] INFO org.hibernate.cfg.Environment - loaded properties from resource hibernate.properties: {hibernate.connection.username=root, hibernate.connection.password=****, hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost/events_calendar, hibernate.bytecode.use_reflection_optimizer=false, hibernate.connection.driver_class=com.mysql.jdbc.Driver}
[java] 32 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : cglib
[java] 74 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
[java] Welcome to Event Calendar 2005.
[java] 738 [main] WARN com.manning.hq.ch02.EventCalendar2 - Welcome to Event Calender v2 2005
[java] 739 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
[java] 739 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
[java] 2421 [main] DEBUG org.hibernate.util.DTDEntityResolver - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd]
[java] 2422 [main] DEBUG org.hibernate.util.DTDEntityResolver - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
[java] 2431 [main] DEBUG org.hibernate.util.DTDEntityResolver - unable to locate [http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd] on classpath
[java] 2432 [main] ERROR org.hibernate.util.DTDEntityResolver - Don't use old DTDs, read the Hibernate 3.x Migration Guide!
[java] 4796 [main] DEBUG org.hibernate.cfg.Configuration - null<-org.dom4j.tree.DefaultAttribute@8c436b [Attribute: name resource value "com/manning/hq/ch02/Event.hbm.xml"]
[java] 4797 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : com/manning/hq/ch02/Event.hbm.xml
[java] 4800 [main] DEBUG org.hibernate.util.DTDEntityResolver - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd]
[java] 4800 [main] DEBUG org.hibernate.util.DTDEntityResolver - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
[java] 4808 [main] DEBUG org.hibernate.util.DTDEntityResolver - unable to locate [http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd] on classpath
[java] 4809 [main] ERROR org.hibernate.util.DTDEntityResolver - Don't use old DTDs, read the Hibernate 3.x Migration Guide!
[java] 5948 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: com.manning.hq.ch02.Event -> events
[java] 6006 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: id -> uid
[java] 6132 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: name -> name
[java] 6133 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
[java] 6133 [main] DEBUG org.hibernate.cfg.Configuration - properties: {java.runtime.name=Java(TM) SE Runtime Environment, hibernate.connection.password=root, sun.boot.library.path=C:\Program Files\Java\jre1.6.0\bin, java.vm.version=1.6.0-oem-b104, ant.library.dir=d:\JBEclipse\plugins\org.apache.ant_1.6.5\lib, hibernate.connection.username=root, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=US, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\work\calendar, java.runtime.version=1.6.0-oem-b104, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\Program Files\Java\jre1.6.0\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\Users\sreevals\AppData\Local\Temp\, line.separator=
[java] , java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows Vista, ant.home=d:\JBEclipse\plugins\org.apache.ant_1.6.5, sun.jnu.encoding=Cp1252, java.library.path=C:\Windows\system32;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\9.0\DLLShared\;C:\jdk1.5.0_09\bin\;C:\apache-maven-2.0.9\bin\;C:\applications\apache-ant-1.7.1\bin\;C:\applications\mysql\bin;d:\JBEclipse\configuration\org.eclipse.osgi\bundles\114\1\.cp, java.specification.name=Java Platform API Specification, java.class.version=50.0, sun.management.compiler=HotSpot Client Compiler, os.version=6.0, user.home=C:\Users\sreevals, user.timezone=Asia/Calcutta, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.6, hibernate.connection.driver_class=com.mysql.jdbc.Driver, java.class.path=D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-antlr.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-apache-bcel.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-apache-bsf.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-apache-log4j.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-apache-oro.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-apache-regexp.jar;D:\JBEclipse\plugins\org.apache.ant_1.6 .5\lib\ant-apache-resolver.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-commons-logging.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-commons-net.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-icontract.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-jai.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-javamail.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-jdepend.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-jmf.jar;D:\JBEclipse\plugins\org.apa che.ant_1.6.5\lib\ant-jsch.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-junit.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-launcher.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-netrexx.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-nodeps.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-starteam.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-stylebook.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-swing.jar;D:\JBEclipse\plugins\org.apache.ant_ 1.6.5\lib\ant-trax.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-vaj.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-weblogic.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-xalan1.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-xslp.jar;D:\JBEclipse\configuration\org.eclipse.osgi\bundles\68\1\.cp\lib\remoteAnt.jar;C:\jdk1.5.0_09\lib\tools.jar;D:\JBEclipse\plugins\org.eclipse.swt.win32.win32.x86_3.1.1.jar, user.name=sreevals, hibernate.bytecode.use_reflection_optimizer=false, java.vm.specification.version=1.0, java.home=C:\Program Files\Java\jre1.6.0, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost/events_calendar, user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, sharing, java.version=1.6.0-oem, java.ext.dirs=C:\Program Files\Java\jre1.6.0\lib\ext;C:\Windows\Sun\Java\lib\ext, sun.boot.class.path=C:\Program Files\Java\jre1.6.0\lib\resources.jar;C:\Program Files\Java\jre1.6.0\lib\rt.jar;C:\Program Files\Java\jre1.6.0\lib\sunrsasign.jar;C:\Program Files\Java\jre1.6.0\lib\jsse.jar;C:\Program Files\Java\jre1.6.0\lib\jce.jar;C:\Program Files\Java\jre1.6.0\lib\charsets.jar;C:\Program Files\Java\jre1.6.0\classes, java.vendor=Sun Microsystems Inc., file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.desktop=windows, sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86}
[java] 6139 [main] DEBUG org.hibernate.cfg.Configuration - Preparing to build session factory with filters : {}
[java] 6140 [main] DEBUG org.hibernate.cfg.Configuration - processing extends queue
[java] 6141 [main] DEBUG org.hibernate.cfg.Configuration - processing collection mappings
[java] 6142 [main] DEBUG org.hibernate.cfg.Configuration - processing native query and ResultSetMapping mappings
[java] 6142 [main] DEBUG org.hibernate.cfg.Configuration - processing association property references
[java] 6142 [main] DEBUG org.hibernate.cfg.Configuration - processing foreign key constraints
[java] 6795 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
[java] 6796 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
[java] 6796 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
[java] 6831 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/events_calendar
[java] 6835 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=root, password=root}
[java] 6836 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
[java] 6837 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - opening new JDBC connection
[java] 7583 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - created connection to: jdbc:mysql://localhost/events_calendar, Isolation Level: 4
[java] 7585 [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 5.0.67-community-nt
[java] 7585 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.4 ( $Date: 2006-10-19 17:47:48 +0200 (Thu, 19 Oct 2006) $, $Revision: 5908 $ )
[java] 7585 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1
[java] 7973 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
[java] 8028 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
[java] 8055 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
[java] 8055 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
[java] 8061 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
[java] 8062 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
[java] 8062 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
[java] 8072 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
[java] 8073 [main] DEBUG org.hibernate.cfg.SettingsFactory - Wrap result sets: disabled
[java] 8073 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
[java] 8074 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
[java] 8085 [main] INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
[java] 8086 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
[java] 8087 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
[java] 8087 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
[java] 8087 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[java] 8132 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
[java] 8132 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
[java] 8132 [main] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
[java] 8133 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
[java] 8133 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
[java] 8133 [main] INFO org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.NoCacheProvider
[java] 8134 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
[java] 8134 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
[java] 8144 [main] DEBUG org.hibernate.exception.SQLExceptionConverterFactory - Using dialect defined converter
[java] 8231 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
[java] 8231 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
[java] 8231 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
[java] 8232 [main] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
[java] 8515 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
[java] 8526 [main] DEBUG org.hibernate.impl.SessionFactoryImpl - Session factory constructed with filter configurations : {}
[java] 8526 [main] DEBUG org.hibernate.impl.SessionFactoryImpl - instantiating session factory with properties: {java.runtime.name=Java(TM) SE Runtime Environment, hibernate.connection.password=root, sun.boot.library.path=C:\Program Files\Java\jre1.6.0\bin, java.vm.version=1.6.0-oem-b104, ant.library.dir=d:\JBEclipse\plugins\org.apache.ant_1.6.5\lib, hibernate.connection.username=root, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=US, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\work\calendar, java.runtime.version=1.6.0-oem-b104, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\Program Files\Java\jre1.6.0\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\Users\sreevals\AppData\Local\Temp\, line.separator=
[java] , java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows Vista, ant.home=d:\JBEclipse\plugins\org.apache.ant_1.6.5, sun.jnu.encoding=Cp1252, java.library.path=C:\Windows\system32;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\9.0\DLLShared\;C:\jdk1.5.0_09\bin\;C:\apache-maven-2.0.9\bin\;C:\applications\apache-ant-1.7.1\bin\;C:\applications\mysql\bin;d:\JBEclipse\configuration\org.eclipse.osgi\bundles\114\1\.cp, java.specification.name=Java Platform API Specification, java.class.version=50.0, sun.management.compiler=HotSpot Client Compiler, os.version=6.0, user.home=C:\Users\sreevals, user.timezone=Asia/Calcutta, java.awt.printerjob=sun.awt.windows.WPrinterJob, java.specification.version=1.6, file.encoding=Cp1252, hibernate.connection.driver_class=com.mysql.jdbc.Driver, user.name=sreevals, java.class.path=D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-antlr.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-apache-bcel.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-apache-bsf.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-apache-log4j.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-apache-oro.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-apache-regexp.jar;D:\JBEclipse\plugins\org.apache.ant_1.6 .5\lib\ant-apache-resolver.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-commons-logging.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-commons-net.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-icontract.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-jai.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-javamail.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-jdepend.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-jmf.jar;D:\JBEclipse\plugins\org.apa che.ant_1.6.5\lib\ant-jsch.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-junit.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-launcher.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-netrexx.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-nodeps.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-starteam.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-stylebook.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-swing.jar;D:\JBEclipse\plugins\org.apache.ant_ 1.6.5\lib\ant-trax.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-vaj.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-weblogic.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-xalan1.jar;D:\JBEclipse\plugins\org.apache.ant_1.6.5\lib\ant-xslp.jar;D:\JBEclipse\configuration\org.eclipse.osgi\bundles\68\1\.cp\lib\remoteAnt.jar;C:\jdk1.5.0_09\lib\tools.jar;D:\JBEclipse\plugins\org.eclipse.swt.win32.win32.x86_3.1.1.jar, hibernate.bytecode.use_reflection_optimizer=false, java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=C:\Program Files\Java\jre1.6.0, hibernate.connection.url=jdbc:mysql://localhost/events_calendar, hibernate.dialect=org.hibernate.dialect.MySQLDialect, java.specification.vendor=Sun Microsystems Inc., user.language=en, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, sharing, java.version=1.6.0-oem, java.ext.dirs=C:\Program Files\Java\jre1.6.0\lib\ext;C:\Windows\Sun\Java\lib\ext, sun.boot.class.path=C:\Program Files\Java\jre1.6.0\lib\resources.jar;C:\Program Files\Java\jre1.6.0\lib\rt.jar;C:\Program Files\Java\jre1.6.0\lib\sunrsasign.jar;C:\Program Files\Java\jre1.6.0\lib\jsse.jar;C:\Program Files\Java\jre1.6.0\lib\jce.jar;C:\Program Files\Java\jre1.6.0\lib\charsets.jar;C:\Program Files\Java\jre1.6.0\classes, java.vendor=Sun Microsystems Inc., file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.cpu.endian=little, sun.io.unicode.encoding=UnicodeLittle, sun.desktop=windows, sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86}
[java] 10342 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Static SQL for entity: com.manning.hq.ch02.Event
[java] 10343 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Version select: select uid from events where uid =?
[java] 10343 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Snapshot select: select event_.uid, event_.name as name0_ from events event_ where event_.uid=?
[java] 10344 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Insert 0: insert into events (name, uid) values (?, ?)
[java] 10344 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Update 0: update events set name=? where uid=?
[java] 10344 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Delete 0: delete from events where uid=?
[java] 10344 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Identity insert: insert into events (name) values (?)
[java] 10509 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity com.manning.hq.ch02.Event: select event0_.uid as uid0_0_, event0_.name as name0_0_ from events event0_ where event0_.uid=?
[java] 10510 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity com.manning.hq.ch02.Event: select event0_.uid as uid0_0_, event0_.name as name0_0_ from events event0_ where event0_.uid=?
[java] 10510 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity com.manning.hq.ch02.Event: select event0_.uid as uid0_0_, event0_.name as name0_0_ from events event0_ where event0_.uid=? for update
[java] 10510 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity com.manning.hq.ch02.Event: select event0_.uid as uid0_0_, event0_.name as name0_0_ from events event0_ where event0_.uid=? for update
[java] 10511 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity com.manning.hq.ch02.Event: select event0_.uid as uid0_0_, event0_.name as name0_0_ from events event0_ where event0_.uid=? for update
[java] 10637 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for action ACTION_MERGE on entity com.manning.hq.ch02.Event: select event0_.uid as uid0_0_, event0_.name as name0_0_ from events event0_ where event0_.uid=?
[java] 10637 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for action ACTION_REFRESH on entity com.manning.hq.ch02.Event: select event0_.uid as uid0_0_, event0_.name as name0_0_ from events event0_ where event0_.uid=?
[java] 10650 [main] DEBUG org.hibernate.impl.SessionFactoryObjectFactory - initializing class SessionFactoryObjectFactory
[java] 10671 [main] DEBUG org.hibernate.impl.SessionFactoryObjectFactory - registered: fb6c03851cbd97ff011cbd98087b0000 (unnamed)
[java] 10672 [main] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
[java] 10672 [main] DEBUG org.hibernate.impl.SessionFactoryImpl - instantiated session factory
[java] 10673 [main] DEBUG org.hibernate.impl.SessionFactoryImpl - Checking 0 named HQL queries
[java] 10673 [main] DEBUG org.hibernate.impl.SessionFactoryImpl - Checking 0 named SQL queries
[java] 11026 [main] DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 12229515695
[java] 11055 [main] DEBUG org.hibernate.event.def.DefaultSaveOrUpdateEventListener - saving transient instance
[java] 11066 [main] DEBUG org.hibernate.event.def.AbstractSaveEventListener - saving [com.manning.hq.ch02.Event#<null>]
[java] 11066 [main] DEBUG org.hibernate.event.def.AbstractSaveEventListener - executing insertions
[java] 11171 [main] DEBUG org.hibernate.event.def.AbstractSaveEventListener - executing identity-insert immediately
[java] 11171 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Inserting entity: com.manning.hq.ch02.Event (native id)
[java] 11180 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[java] 11181 [main] DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
[java] 11181 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
[java] 11181 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0
[java] 11183 [main] DEBUG org.hibernate.SQL - insert into events (name) values (?)
[java] 11183 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
[java] 11238 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Dehydrating entity: [com.manning.hq.ch02.Event#<null>]
[java] 11238 [main] DEBUG org.hibernate.type.StringType - binding 'ABCD' to parameter: 1
[java] 11240 [main] DEBUG org.hibernate.id.IdentifierGeneratorFactory - Natively generated identity: 14
[java] 11241 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
[java] 11241 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
[java] 11269 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - flushing session
[java] 11279 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades
[java] 11291 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
[java] 11291 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections
[java] 11317 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections
[java] 11317 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates
[java] 11319 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
[java] 11319 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
[java] 11332 [main] DEBUG org.hibernate.pretty.Printer - listing entities:
[java] 11334 [main] DEBUG org.hibernate.pretty.Printer - com.manning.hq.ch02.Event{id=14, name=ABCD}
[java] 11334 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - executing flush
[java] 11334 [main] DEBUG org.hibernate.jdbc.ConnectionManager - registering flush begin
[java] 11335 [main] DEBUG org.hibernate.jdbc.ConnectionManager - registering flush end
[java] 11335 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - post flush
[java] 11335 [main] DEBUG org.hibernate.impl.SessionImpl - closing session
[java] 11335 [main] DEBUG org.hibernate.jdbc.ConnectionManager - performing cleanup
[java] 11336 [main] DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
[java] 11347 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1
[java] 11348 [main] DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion
[java] 11348 [main] DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
[java] 11348 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion
[echo] If you see this, it runs
BUILD SUCCESSFUL

--------------------------------

Please help, as its very critical for me to understand hibernate. thanks in advance.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"shilpa", please check your private messages.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will need to read the documentation about transactions to fix your problem.
 
shilpa menon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for your response..

Can I atleast make sure the following (1,2, and 3) from the lines i could see in the stack (A, B, and C)

1.that the configurations are correct
2.it identifies the table in database and
3.it binds the values set for POJO (Event.java)

A

[java] 5948 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: com.manning.hq.ch02.Event -> events[java] 6006 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: id -> uid

B

[java] 6132 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: name -> name

C

[java] 11334 [main] DEBUG org.hibernate.pretty.Printer - com.manning.hq.ch02.Event{id=14, name=ABCD}
----------------------------------------------------
From another such forum i saw an advice to turn on auto commit to true. And in my stack trace it appears as;-

[java] 6796 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false

Can you please tell me how to turn this on ?

Please guide me ..
 
shilpa menon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of sessionfactory.openSession(); i ve tried using sessionfactory.getCurrentSession(); to obtain the session. Also, before calling save i have invoked session.beginTransaction(); but then i am getting org.hibernate.HibernateException: No CurrentSessionContext configured!. The new form of code resulted in this exception is below,


Configuration cfg=new Configuration();
SessionFactory factory = cfg.configure().buildSessionFactory();
Session session = factory.getCurrentSession();//new modification
session.beginTransaction();//new modification
Event testevent = new Event();
testevent.setName("ABCD");
session.save(testevent);
session.getTransaction().commit();//new modification
session.flush();

Please help me in this regard....
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shilpa,

As Paul pointed out, you need to use transactions to save your data. The common usage is explained in the javadocs of Hibernate Session. Look for the typical transaction usage example there.
 
shilpa menon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much Jai and Paul

It works !!!. The typical transaction usage example given in javadocs of Hibernate was really useful. Now, the modified (working) code is as given below



It was really a wayblocker. Now i can learn and experiment further. Thanks for the great help.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.. I am facing the same problem. I need to insert a list of data. I am using session.flush() and transaction.commit(). I am getting the new values in the next page. The wonder is the values are not inserted in the table. Log shows no error. I dont know how the datas are displayed in the next page.

My code is
Iterator it = list.iterator();
Transaction tr = session.beginTransaction();
while (it.hasNext()) {
trend = new Trend();

VO = (VO) it.next();
trend.setId(VO.getId());
orclSession.save(trendVO);
orclSession.flush();
tr.commit();
 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OMG, who can read and understand that code you posted here? You create a new Trend-Object, set its ID, then you save another object called trendVO. You do not show any mappings, no configuration, you do not even close the while-statement. But we have to guess what the real code looks like?
 
Prabu Pidaran
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Christian Dillinger ...

I have a list which is fetched from MS SQL Server 2005 and the same list has to be inserted into Oracle database. I am using Websphere 6.1 and Hibernate 3.0. I have created "Oracle JDBC Driver XA DataSource" - for Oracle Database and "WebSphere embedded ConnectJDBC for SQL Server XA DataSource" - for SQL Server 2005.I am using the following code to insert the list into Oracle Database. But the data not getting inserted. Log shows no error.

Iterator it = list.iterator();
Transaction tr = session.beginTransaction();
while (it.hasNext()) {
trend = new Trend();

VO = (VO) it.next();
trend.setId(VO.getId());
trend.setName(VO.getName());
orclSession.save(trend);
orclSession.flush();
}
tr.commit();

 
Christian Dillinger
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you turn on show_sql? If so, do you see insert statements? Are you sure your class Trend is listed in hibernate.cfg.xml? Is the class listed in the JBoss log when your app gets deployed?
 
Prabu Pidaran
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah.. I have turned on show_sql (<property name="show_sql">true</property>). My class Trend is listed in hibernate.cfg.xml.( <mapping resource="com/vo/Trend.hbm.xml"/>)... I am not getting what you are asking -->Is the class listed in the JBoss log when your app gets deployed? .
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Shilpa, Jai and Paul.... your inputs were very helpful for me...
 
reply
    Bookmark Topic Watch Topic
  • New Topic