I reference the document hibernate_reference.pdf attached in the hibernate-distribution-3.6.0.CR2-dist.zip to learn the tutorial.
I wrote the code after reading the section 1.1.7. Loading and storing objects and run my application but I got the following exception messages in my console:
20:05:35,359 INFO Version:37 - Hibernate Commons Annotations 3.2.0.Final
20:05:35,375 INFO Environment:593 - Hibernate 3.6.0.CR2
20:05:35,375 INFO Environment:626 - hibernate.properties not found
20:05:35,375 INFO Environment:804 - Bytecode provider name : javassist
20:05:35,375 INFO Environment:685 - using JDK 1.4 java.sql.Timestamp handling
20:05:35,421 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [uuid2] -> [class org.hibernate.id.UUIDGenerator]
20:05:35,437 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [guid] -> [class org.hibernate.id.GUIDGenerator]
20:05:35,437 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [uuid] -> [class org.hibernate.id.UUIDHexGenerator]
20:05:35,437 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [uuid.hex] -> [class org.hibernate.id.UUIDHexGenerator]
20:05:35,437 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [hilo] -> [class org.hibernate.id.TableHiLoGenerator]
20:05:35,437 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [assigned] -> [class org.hibernate.id.Assigned]
20:05:35,437 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [identity] -> [class org.hibernate.id.IdentityGenerator]
20:05:35,437 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [select] -> [class org.hibernate.id.SelectGenerator]
20:05:35,437 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [sequence] -> [class org.hibernate.id.SequenceGenerator]
20:05:35,437 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [seqhilo] -> [class org.hibernate.id.SequenceHiLoGenerator]
20:05:35,437 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [increment] -> [class org.hibernate.id.IncrementGenerator]
20:05:35,453 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [foreign] -> [class org.hibernate.id.ForeignGenerator]
20:05:35,453 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [sequence-identity] -> [class org.hibernate.id.SequenceIdentityGenerator]
20:05:35,453 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [enhanced-sequence] -> [class org.hibernate.id.enhanced.SequenceStyleGenerator]
20:05:35,453 DEBUG DefaultIdentifierGeneratorFactory:100 - Registering IdentifierGenerator strategy [enhanced-table] -> [class org.hibernate.id.enhanced.TableGenerator]
20:05:35,453 INFO Configuration:2124 - configuring from resource: /hibernate.cfg.xml
20:05:35,453 INFO Configuration:2143 - Configuration resource: /hibernate.cfg.xml
20:05:35,500 DEBUG DTDEntityResolver:67 - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
20:05:35,500 WARN DTDEntityResolver:73 - recognized obsolete hibernate namespace
http://hibernate.sourceforge.net/. Use namespace
http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
20:05:35,500 DEBUG DTDEntityResolver:77 - attempting to resolve on classpath under org/hibernate/
20:05:35,500 DEBUG DTDEntityResolver:109 - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
20:05:35,531 DEBUG Configuration:2086 - connection.driver_class=com.mysql.jdbc.Driver
20:05:35,531 DEBUG Configuration:2086 - connection.url=jdbc:mysql://localhost:3306/test
20:05:35,531 DEBUG Configuration:2086 - connection.username=root
20:05:35,531 DEBUG Configuration:2086 - connection.password=admin
20:05:35,531 DEBUG Configuration:2086 - connection.pool_size=1
20:05:35,531 DEBUG Configuration:2086 - dialect=org.hibernate.dialect.MySQLDialect
20:05:35,531 DEBUG Configuration:2086 - current_session_context_class=thread
20:05:35,531 DEBUG Configuration:2086 - cache.provider_class=org.hibernate.cache.NoCacheProvider
20:05:35,531 DEBUG Configuration:2086 - show_sql=true
20:05:35,531 DEBUG Configuration:2086 - hbm2ddl.auto=update
20:05:35,531 DEBUG Configuration:2311 - session-factory config [null] named resource [org/hibernate/tutorial/domain/Event.hbm.xml] for mapping
20:05:35,531 INFO Configuration:757 - Reading mappings from resource : org/hibernate/tutorial/domain/Event.hbm.xml
20:05:35,562 DEBUG DTDEntityResolver:67 - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
20:05:35,562 WARN DTDEntityResolver:73 - recognized obsolete hibernate namespace
http://hibernate.sourceforge.net/. Use namespace
http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
20:05:35,562 DEBUG DTDEntityResolver:77 - attempting to resolve on classpath under org/hibernate/
20:05:35,562 DEBUG DTDEntityResolver:109 - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
20:05:35,609 INFO Configuration:2265 - Configured SessionFactory: null
20:05:35,609 DEBUG Configuration:2266 - properties: {java.vendor=Sun Microsystems Inc., show_sql=true, hibernate.connection.url=jdbc:mysql://localhost:3306/test, sun.management.compiler=HotSpot Client Compiler, os.name=Windows XP, hbm2ddl.auto=update, sun.boot.class.path=C:\zzx\ITSE\Java\jdk150_06\jre\lib\rt.jar;C:\zzx\ITSE\Java\jdk150_06\jre\lib\i18n.jar;C:\zzx\ITSE\Java\jdk150_06\jre\lib\sunrsasign.jar;C:\zzx\ITSE\Java\jdk150_06\jre\lib\jsse.jar;C:\zzx\ITSE\Java\jdk150_06\jre\lib\jce.jar;C:\zzx\ITSE\Java\jdk150_06\jre\lib\charsets.jar;C:\zzx\ITSE\Java\jdk150_06\jre\classes, hibernate.current_session_context_class=thread, sun.desktop=windows, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.5.0_06-b05, hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider, user.name=zhanzhex, connection.driver_class=com.mysql.jdbc.Driver, current_session_context_class=thread, user.language=en, sun.boot.library.path=C:\zzx\ITSE\Java\jdk150_06\jre\bin, dialect=org.hibernate.dialect.MySQLDialect, java.version=1.5.0_06, user.timezone=Asia/Shanghai, sun.arch.data.model=32, java.endorsed.dirs=C:\zzx\ITSE\Java\jdk150_06\jre\lib\endorsed, sun.cpu.isalist=, sun.jnu.encoding=Cp1252, file.encoding.pkg=sun.io, file.separator=\, java.specification.name=Java Platform API Specification, java.class.version=49.0, user.country=US, connection.url=jdbc:mysql://localhost:3306/test, java.home=C:\zzx\ITSE\Java\jdk150_06\jre, java.vm.info=mixed mode, os.version=5.1, path.separator=;, connection.password=admin, java.vm.version=1.5.0_06-b05, hibernate.connection.password=admin, user.variant=, java.awt.printerjob=sun.awt.windows.WPrinterJob, sun.io.unicode.encoding=UnicodeLittle, awt.toolkit=sun.awt.windows.WToolkit, hibernate.connection.username=root, user.home=C:\Documents and Settings\zhanzhex, java.specification.vendor=Sun Microsystems Inc., hibernate.hbm2ddl.auto=update, java.library.path=C:\zzx\ITSE\Java\jdk150_06\bin;.;C:\WINDOWS\system32;C:\WINDOWS;c:/Program Files/Java/jre6/bin/client;c:/Program Files/Java/jre6/bin;c:/Program Files/Java/jre6/lib/i386;C:\Program Files\RA2HP\;C:\oracle\product\10.2.0\db_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Program Files\ActivIdentity\ActivClient\;C:\Program Files\MySQL\MySQL Server 5.1\bin, java.vendor.url=http://java.sun.com/, hibernate.connection.driver_class=com.mysql.jdbc.Driver, connection.username=root, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=org.hibernate.dialect.MySQLDialect, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, java.class.path=C:\ITSE\Java\WorkSpace\Hibernate\bin;C:\ITSE\Java\WorkSpace\Hibernate\antlr-2.7.6.jar;C:\ITSE\Java\WorkSpace\Hibernate\commons-collections-3.1.jar;C:\ITSE\Java\WorkSpace\Hibernate\dom4j-1.6.1.jar;C:\ITSE\Java\WorkSpace\Hibernate\javassist-3.12.0.GA.jar;C:\ITSE\Java\WorkSpace\Hibernate\jta-1.1.jar;C:\ITSE\Java\WorkSpace\Hibernate\slf4j-api-1.6.1.jar;C:\ITSE\Java\WorkSpace\Hibernate\hibernate3.jar;C:\ITSE\Java\WorkSpace\Hibernate\log4j-1.2.16.jar;C:\ITSE\Java\WorkSpace\Hibernate\hibernate-jpa-2.0-api-1.0.0.Final.jar;C:\ITSE\Java\WorkSpace\Hibernate\mysql-connector-java-5.1.13-bin.jar;C:\ITSE\Java\WorkSpace\Hibernate\slf4j-log4j12-1.6.1.jar, hibernate.bytecode.use_reflection_optimizer=false, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, sun.cpu.endian=little, sun.os.patch.level=Service Pack 3, connection.pool_size=1, java.io.tmpdir=C:\DOCUME~1\zhanzhex\LOCALS~1\Temp\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, os.arch=x86, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.ext.dirs=C:\zzx\ITSE\Java\jdk150_06\jre\lib\ext, user.dir=C:\ITSE\Java\WorkSpace\Hibernate, line.separator=
, java.vm.name=Java HotSpot(TM) Client VM, cache.provider_class=org.hibernate.cache.NoCacheProvider, file.encoding=Cp1252, java.specification.version=1.5, hibernate.show_sql=true, hibernate.connection.pool_size=1}
20:05:35,609 DEBUG Configuration:1822 - Preparing to build session factory with filters : {}
20:05:35,640 DEBUG Configuration:3922 - Processing hbm.xml files
20:05:35,671 INFO HbmBinder:350 - Mapping class: org.hibernate.tutorial.domain.Event -> EVENTS
20:05:35,671 DEBUG HbmBinder:1337 - Mapped property: id -> EVENT_ID
20:05:35,671 DEBUG HbmBinder:1337 - Mapped property: date -> EVENT_DATE
20:05:35,671 DEBUG HbmBinder:1337 - Mapped property: title -> title
20:05:35,671 DEBUG Configuration:3952 - Process annotated classes
20:05:35,687 DEBUG Configuration:1434 - processing fk mappings (*ToOne and JoinedSubclass)
20:05:35,687 DEBUG Configuration:1676 - processing extends queue
20:05:35,687 DEBUG Configuration:1730 - processing extends queue
20:05:35,687 DEBUG Configuration:1679 - processing collection mappings
20:05:35,687 DEBUG Configuration:1689 - processing native query and ResultSetMapping mappings
20:05:35,687 DEBUG Configuration:1697 - processing association property references
20:05:35,687 DEBUG Configuration:1719 - processing foreign key constraints
20:05:35,687 INFO Configuration:1644 - Hibernate Validator not found: ignoring
20:05:35,687 DEBUG Configuration:1864 - Legacy Validator not present in classpath, ignoring event listener registration
20:05:35,687 DEBUG HibernateSearchEventListenerRegister:231 - Search not present in classpath, ignoring event listener registration.
20:05:35,687 INFO HibernateSearchEventListenerRegister:75 - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
20:05:35,687 INFO DriverManagerConnectionProvider:64 - Using Hibernate built-in connection pool (not for production use!)
20:05:35,703 INFO DriverManagerConnectionProvider:65 - Hibernate connection pool size: 1
20:05:35,703 INFO DriverManagerConnectionProvider:68 - autocommit mode: false
20:05:35,703 INFO DriverManagerConnectionProvider:103 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/test
20:05:35,703 INFO DriverManagerConnectionProvider:106 - connection properties: {user=root, password=admin}
20:05:35,703 DEBUG DriverManagerConnectionProvider:132 - opening new JDBC connection
20:05:36,203 DEBUG DriverManagerConnectionProvider:138 - created connection to: jdbc:mysql://localhost:3306/test, Isolation Level: 4
20:05:36,203 INFO SettingsFactory:117 - Database ->
name : MySQL
version : 5.1.48-community
major : 5
minor : 1
20:05:36,203 INFO SettingsFactory:123 - Driver ->
name : MySQL-AB JDBC Driver
version : mysql-connector-java-5.1.13 ( Revision: ${bzr.revision-id} )
major : 5
minor : 1
20:05:36,312 INFO Dialect:108 - Using dialect: org.hibernate.dialect.MySQLDialect
20:05:36,375 INFO JdbcSupportLoader:79 - Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
20:05:36,421 INFO TransactionFactoryFactory:59 - Using default transaction strategy (direct JDBC transactions)
20:05:36,421 INFO TransactionManagerLookupFactory:80 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
20:05:36,421 INFO SettingsFactory:179 - Automatic flush during beforeCompletion(): disabled
20:05:36,421 INFO SettingsFactory:183 - Automatic session close at end of transaction: disabled
20:05:36,421 INFO SettingsFactory:190 - JDBC batch size: 15
20:05:36,421 INFO SettingsFactory:193 - JDBC batch updates for versioned data: disabled
20:05:36,421 INFO SettingsFactory:198 - Scrollable result sets: enabled
20:05:36,421 DEBUG SettingsFactory:202 - Wrap result sets: disabled
20:05:36,421 INFO SettingsFactory:206 - JDBC3 getGeneratedKeys(): enabled
20:05:36,421 INFO SettingsFactory:214 - Connection release mode: auto
20:05:36,484 INFO SettingsFactory:238 - Maximum outer join fetch depth: 2
20:05:36,484 INFO SettingsFactory:241 - Default batch fetch size: 1
20:05:36,484 INFO SettingsFactory:245 - Generate SQL with comments: disabled
20:05:36,484 INFO SettingsFactory:249 - Order SQL updates by primary key: disabled
20:05:36,484 INFO SettingsFactory:253 - Order SQL inserts for batching: disabled
20:05:36,484 INFO SettingsFactory:431 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
20:05:36,500 INFO ASTQueryTranslatorFactory:47 - Using ASTQueryTranslatorFactory
20:05:36,500 INFO SettingsFactory:261 - Query language substitutions: {}
20:05:36,500 INFO SettingsFactory:266 - JPA-QL strict compliance: disabled
20:05:36,500 INFO SettingsFactory:271 - Second-level cache: enabled
20:05:36,500 INFO SettingsFactory:275 - Query cache: disabled
20:05:36,531 INFO SettingsFactory:406 - Cache region factory : org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
20:05:36,531 INFO RegionFactoryCacheProviderBridge:61 - Cache provider: org.hibernate.cache.NoCacheProvider
20:05:36,531 INFO SettingsFactory:285 - Optimize cache for minimal puts: disabled
20:05:36,531 INFO SettingsFactory:294 - Structured second-level cache entries: disabled
20:05:36,546 INFO SettingsFactory:314 - Echoing all SQL to stdout
20:05:36,546 INFO SettingsFactory:323 - Statistics: disabled
20:05:36,546 INFO SettingsFactory:327 - Deleted entity synthetic identifier rollback: disabled
20:05:36,546 INFO SettingsFactory:343 - Default entity-mode: pojo
20:05:36,546 INFO SettingsFactory:347 - Named query checking : enabled
20:05:36,546 INFO SettingsFactory:351 - Check Nullability in Core (should be disabled when Bean Validation is on): enabled
20:05:36,625 INFO SessionFactoryImpl:200 - building session factory
20:05:36,625 DEBUG SessionFactoryImpl:204 - Statistics initialized [enabled=false]}
20:05:36,656 DEBUG SessionFactoryImpl:226 - Session factory constructed with filter configurations : {}
20:05:36,656 DEBUG SessionFactoryImpl:230 - instantiating session factory with properties: {java.vendor=Sun Microsystems Inc., show_sql=true, hibernate.connection.url=jdbc:mysql://localhost:3306/test, sun.management.compiler=HotSpot Client Compiler, os.name=Windows XP, hbm2ddl.auto=update, sun.boot.class.path=C:\zzx\ITSE\Java\jdk150_06\jre\lib\rt.jar;C:\zzx\ITSE\Java\jdk150_06\jre\lib\i18n.jar;C:\zzx\ITSE\Java\jdk150_06\jre\lib\sunrsasign.jar;C:\zzx\ITSE\Java\jdk150_06\jre\lib\jsse.jar;C:\zzx\ITSE\Java\jdk150_06\jre\lib\jce.jar;C:\zzx\ITSE\Java\jdk150_06\jre\lib\charsets.jar;C:\zzx\ITSE\Java\jdk150_06\jre\classes, hibernate.current_session_context_class=thread, sun.desktop=windows, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.5.0_06-b05, hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider, user.name=zhanzhex, connection.driver_class=com.mysql.jdbc.Driver, current_session_context_class=thread, user.language=en, sun.boot.library.path=C:\zzx\ITSE\Java\jdk150_06\jre\bin, dialect=org.hibernate.dialect.MySQLDialect, java.version=1.5.0_06, user.timezone=Asia/Shanghai, sun.arch.data.model=32, java.endorsed.dirs=C:\zzx\ITSE\Java\jdk150_06\jre\lib\endorsed, sun.cpu.isalist=, sun.jnu.encoding=Cp1252, file.encoding.pkg=sun.io, file.separator=\, java.specification.name=Java Platform API Specification, java.class.version=49.0, user.country=US, connection.url=jdbc:mysql://localhost:3306/test, java.home=C:\zzx\ITSE\Java\jdk150_06\jre, java.vm.info=mixed mode, os.version=5.1, path.separator=;, connection.password=admin, java.vm.version=1.5.0_06-b05, hibernate.connection.password=admin, user.variant=, java.awt.printerjob=sun.awt.windows.WPrinterJob, sun.io.unicode.encoding=UnicodeLittle, awt.toolkit=sun.awt.windows.WToolkit, hibernate.connection.username=root, user.home=C:\Documents and Settings\zhanzhex, java.specification.vendor=Sun Microsystems Inc., hibernate.hbm2ddl.auto=update, java.library.path=C:\zzx\ITSE\Java\jdk150_06\bin;.;C:\WINDOWS\system32;C:\WINDOWS;c:/Program Files/Java/jre6/bin/client;c:/Program Files/Java/jre6/bin;c:/Program Files/Java/jre6/lib/i386;C:\Program Files\RA2HP\;C:\oracle\product\10.2.0\db_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Program Files\ActivIdentity\ActivClient\;C:\Program Files\MySQL\MySQL Server 5.1\bin, java.vendor.url=http://java.sun.com/, hibernate.connection.driver_class=com.mysql.jdbc.Driver, connection.username=root, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=org.hibernate.dialect.MySQLDialect, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, java.class.path=C:\ITSE\Java\WorkSpace\Hibernate\bin;C:\ITSE\Java\WorkSpace\Hibernate\antlr-2.7.6.jar;C:\ITSE\Java\WorkSpace\Hibernate\commons-collections-3.1.jar;C:\ITSE\Java\WorkSpace\Hibernate\dom4j-1.6.1.jar;C:\ITSE\Java\WorkSpace\Hibernate\javassist-3.12.0.GA.jar;C:\ITSE\Java\WorkSpace\Hibernate\jta-1.1.jar;C:\ITSE\Java\WorkSpace\Hibernate\slf4j-api-1.6.1.jar;C:\ITSE\Java\WorkSpace\Hibernate\hibernate3.jar;C:\ITSE\Java\WorkSpace\Hibernate\log4j-1.2.16.jar;C:\ITSE\Java\WorkSpace\Hibernate\hibernate-jpa-2.0-api-1.0.0.Final.jar;C:\ITSE\Java\WorkSpace\Hibernate\mysql-connector-java-5.1.13-bin.jar;C:\ITSE\Java\WorkSpace\Hibernate\slf4j-log4j12-1.6.1.jar, hibernate.bytecode.use_reflection_optimizer=false, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, sun.cpu.endian=little, sun.os.patch.level=Service Pack 3, connection.pool_size=1, java.io.tmpdir=C:\DOCUME~1\zhanzhex\LOCALS~1\Temp\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, os.arch=x86, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.ext.dirs=C:\zzx\ITSE\Java\jdk150_06\jre\lib\ext, user.dir=C:\ITSE\Java\WorkSpace\Hibernate, line.separator=
, java.vm.name=Java HotSpot(TM) Client VM, cache.provider_class=org.hibernate.cache.NoCacheProvider, file.encoding=Cp1252, java.specification.version=1.5, hibernate.connection.pool_size=1, hibernate.show_sql=true}
20:05:36,734 DEBUG DefaultIdentifierGeneratorFactory:90 - Setting dialect [org.hibernate.dialect.MySQLDialect]
20:05:37,109 DEBUG AbstractEntityPersister:2934 - Static SQL for entity: org.hibernate.tutorial.domain.Event
20:05:37,109 DEBUG AbstractEntityPersister:2939 - Version select: select EVENT_ID from EVENTS where EVENT_ID =?
20:05:37,109 DEBUG AbstractEntityPersister:2942 - Snapshot select: select event_.EVENT_ID, event_.EVENT_DATE as EVENT2_0_, event_.title as title0_ from EVENTS event_ where event_.EVENT_ID=?
20:05:37,109 DEBUG AbstractEntityPersister:2945 - Insert 0: insert into EVENTS (EVENT_DATE, title, EVENT_ID) values (?, ?, ?)
20:05:37,109 DEBUG AbstractEntityPersister:2946 - Update 0: update EVENTS set EVENT_DATE=?, title=? where EVENT_ID=?
20:05:37,109 DEBUG AbstractEntityPersister:2947 - Delete 0: delete from EVENTS where EVENT_ID=?
20:05:37,109 DEBUG AbstractEntityPersister:2951 - Identity insert: insert into EVENTS (EVENT_DATE, title) values (?, ?)
20:05:37,125 DEBUG EntityLoader:123 - Static select for entity org.hibernate.tutorial.domain.Event [NONE]: select event0_.EVENT_ID as EVENT1_0_0_, event0_.EVENT_DATE as EVENT2_0_0_, event0_.title as title0_0_ from EVENTS event0_ where event0_.EVENT_ID=?
20:05:37,125 DEBUG EntityLoader:123 - Static select for entity org.hibernate.tutorial.domain.Event [READ]: select event0_.EVENT_ID as EVENT1_0_0_, event0_.EVENT_DATE as EVENT2_0_0_, event0_.title as title0_0_ from EVENTS event0_ where event0_.EVENT_ID=?
20:05:37,125 DEBUG EntityLoader:123 - Static select for entity org.hibernate.tutorial.domain.Event [UPGRADE]: select event0_.EVENT_ID as EVENT1_0_0_, event0_.EVENT_DATE as EVENT2_0_0_, event0_.title as title0_0_ from EVENTS event0_ where event0_.EVENT_ID=? for update
20:05:37,125 DEBUG EntityLoader:123 - Static select for entity org.hibernate.tutorial.domain.Event [UPGRADE_NOWAIT]: select event0_.EVENT_ID as EVENT1_0_0_, event0_.EVENT_DATE as EVENT2_0_0_, event0_.title as title0_0_ from EVENTS event0_ where event0_.EVENT_ID=? for update
20:05:37,125 DEBUG EntityLoader:123 - Static select for entity org.hibernate.tutorial.domain.Event [FORCE]: select event0_.EVENT_ID as EVENT1_0_0_, event0_.EVENT_DATE as EVENT2_0_0_, event0_.title as title0_0_ from EVENTS event0_ where event0_.EVENT_ID=? for update
20:05:37,140 DEBUG EntityLoader:123 - Static select for entity org.hibernate.tutorial.domain.Event [PESSIMISTIC_READ]: select event0_.EVENT_ID as EVENT1_0_0_, event0_.EVENT_DATE as EVENT2_0_0_, event0_.title as title0_0_ from EVENTS event0_ where event0_.EVENT_ID=? lock in share mode
20:05:37,140 DEBUG EntityLoader:123 - Static select for entity org.hibernate.tutorial.domain.Event [PESSIMISTIC_WRITE]: select event0_.EVENT_ID as EVENT1_0_0_, event0_.EVENT_DATE as EVENT2_0_0_, event0_.title as title0_0_ from EVENTS event0_ where event0_.EVENT_ID=? for update
20:05:37,140 DEBUG EntityLoader:123 - Static select for entity org.hibernate.tutorial.domain.Event [PESSIMISTIC_FORCE_INCREMENT]: select event0_.EVENT_ID as EVENT1_0_0_, event0_.EVENT_DATE as EVENT2_0_0_, event0_.title as title0_0_ from EVENTS event0_ where event0_.EVENT_ID=? for update
20:05:37,140 DEBUG EntityLoader:123 - Static select for entity org.hibernate.tutorial.domain.Event [OPTIMISTIC]: select event0_.EVENT_ID as EVENT1_0_0_, event0_.EVENT_DATE as EVENT2_0_0_, event0_.title as title0_0_ from EVENTS event0_ where event0_.EVENT_ID=?
20:05:37,140 DEBUG EntityLoader:123 - Static select for entity org.hibernate.tutorial.domain.Event [OPTIMISTIC_FORCE_INCREMENT]: select event0_.EVENT_ID as EVENT1_0_0_, event0_.EVENT_DATE as EVENT2_0_0_, event0_.title as title0_0_ from EVENTS event0_ where event0_.EVENT_ID=?
20:05:37,140 DEBUG EntityLoader:56 - Static select for action ACTION_MERGE on entity org.hibernate.tutorial.domain.Event: select event0_.EVENT_ID as EVENT1_0_0_, event0_.EVENT_DATE as EVENT2_0_0_, event0_.title as title0_0_ from EVENTS event0_ where event0_.EVENT_ID=?
20:05:37,140 DEBUG EntityLoader:56 - Static select for action ACTION_REFRESH on entity org.hibernate.tutorial.domain.Event: select event0_.EVENT_ID as EVENT1_0_0_, event0_.EVENT_DATE as EVENT2_0_0_, event0_.title as title0_0_ from EVENTS event0_ where event0_.EVENT_ID=?
20:05:37,328 DEBUG SessionFactoryObjectFactory:61 - initializing class SessionFactoryObjectFactory
20:05:37,328 DEBUG SessionFactoryObjectFactory:99 - registered: d61c9053-b708-44c5-9b8b-cc55adb2dc22 (unnamed)
20:05:37,328 INFO SessionFactoryObjectFactory:105 - Not binding factory to JNDI, no JNDI name configured
20:05:37,328 DEBUG SessionFactoryImpl:367 - instantiated session factory
20:05:37,328 INFO SchemaUpdate:155 - Running hbm2ddl schema update
20:05:37,328 INFO SchemaUpdate:167 - fetching database metadata
20:05:37,328 INFO SchemaUpdate:179 - updating schema
20:05:37,328 DEBUG Configuration:3922 - Processing hbm.xml files
20:05:37,328 DEBUG Configuration:3952 - Process annotated classes
20:05:37,328 DEBUG Configuration:1434 - processing fk mappings (*ToOne and JoinedSubclass)
20:05:37,343 DEBUG Configuration:1676 - processing extends queue
20:05:37,343 DEBUG Configuration:1730 - processing extends queue
20:05:37,343 DEBUG Configuration:1679 - processing collection mappings
20:05:37,343 DEBUG Configuration:1689 - processing native query and ResultSetMapping mappings
20:05:37,343 DEBUG Configuration:1697 - processing association property references
20:05:37,343 DEBUG Configuration:1719 - processing foreign key constraints
20:05:37,453 INFO TableMetadata:65 - table found: test.events
20:05:37,453 INFO TableMetadata:66 - columns: [event_id, title, event_date]
20:05:37,453 INFO TableMetadata:68 - foreign keys: []
20:05:37,453 INFO TableMetadata:69 - indexes: [primary]
20:05:37,453 DEBUG DefaultIdentifierGeneratorFactory:90 - Setting dialect [org.hibernate.dialect.MySQLDialect]
20:05:37,453 INFO SchemaUpdate:217 - schema update complete
20:05:37,468 DEBUG SessionFactoryImpl:537 - Checking 0 named HQL queries
20:05:37,468 DEBUG SessionFactoryImpl:557 - Checking 0 named SQL queries
20:05:37,578 DEBUG SessionImpl:265 - opened session at timestamp: 12880947375
20:05:37,687 DEBUG JDBCTransaction:78 - begin
20:05:37,687 DEBUG ConnectionManager:444 - opening JDBC connection
20:05:37,703 DEBUG JDBCTransaction:83 - current autocommit status: false
20:05:37,765 DEBUG AbstractSaveEventListener:319 - executing identity-insert immediately
20:05:37,765 DEBUG AbstractBatcher:410 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
20:05:37,765 DEBUG SQL:111 - insert into EVENTS (EVENT_DATE, title) values (?, ?)
Hibernate: insert into EVENTS (EVENT_DATE, title) values (?, ?)
Exception in thread "main" org.hibernate.HibernateException: The database returned no natively generated identity value
at org.hibernate.id.IdentifierGeneratorHelper.getGeneratedIdentity(IdentifierGeneratorHelper.java:84)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:98)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2327)
20:05:37,859 DEBUG AbstractBatcher:418 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2834)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:320)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:203)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:129)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:714)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:702)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:698)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:344)
at $Proxy0.save(Unknown Source)
at org.hibernate.tutorial.manger.EventManager.saveEvent(EventManager.java:25)
at org.hibernate.tutorial.manger.EventManager.main(EventManager.java:34)
I don't know why the hibernate would throws that exception above. According to the content in page 4 in hibernate_reference.pdf it mentioned that :
Only Hibernate will assign identifiers when an object is saved.
The nested generator element specifies the identifier generation strategy (aka how are identifier
values generated?). In this case we choose native, which offers a level of portability depending
on the configured database dialect. Hibernate supports database generated, globally unique, as
well as application assigned, identifiers. Identifier value generation is also one of Hibernate's many
extension points and you can plugin in your own strategy.
So, I think Hibernate will assign the value of the identifier for me, but in fact, it did not.
20:05:37,765 DEBUG SQL:111 - insert into EVENTS (EVENT_DATE, title) values (?, ?)
in Event.hbm.xml and set a value to event_id property in Event instance, then the object could be stored to DB correctly.
So, I want to know how can I use the feature that hibernate will assign the identifier to the application automatically.