Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
I'm trying to store a bidirectional self referencing / recursive one-to-many relationship. I'm having two issues.
- index value is not being saved
- "item_id" is not being saved
I've read
http://www.hibernate.org/193.html but doesn't seem to be working for me. I'm sure I'm not understanding some basic setup about relationships.
Thoughts?
Thanks in advance.
Hibernate version: 3.1
Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.company.Item" table="item">
<id name="id" type="string" unsaved-value="null">
<column name="id" sql-type="char(32)" not-null="true" />
<generator class="uuid.hex" />
</id>
<property name="name" column="name" type="string" length="255" />
<many-to-one name="item" class="com.company.Item"
column="item_id" insert="false" update="false" />
<list name="items" table="item" inverse="false" cascade="all">
<key column="item_id" update="false" />
<list-index column="sequence" />
<one-to-many class="com.company.Item" />
</list>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Item class:
Code:
package com.company;
import java.util.List;
public class Item {
private String id;
private Item item;
private List items;
private String name;
public String getId() {
return id;
}
public Item getItem() {
return item;
}
public List getItems() {
return items;
}
public String getName() {
return name;
}
public void setId(String id) {
this.id = id;
}
public void setItem(Item item) {
this.item = item;
}
public void setItems(List items) {
this.items = items;
}
public void setName(String name) {
this.name = name;
}
}
Test class
Code:
package com.company;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
public class Test {
public static void main(String args[]) {
ClassPathResource resource = new ClassPathResource("applicationContext.xml");
XmlBeanFactory factory = new XmlBeanFactory(resource);
ItemDao itemDao = (ItemDao) factory.getBean("itemDao");
Item item = new Item();
item.setName("test");
itemDao.store(item);
Item subItem = new Item();
subItem.setName("test sub");
subItem.setItem(item);
item.setItems(new ArrayList<Item>());
item.getItems().add(subItem);
itemDao.store(item);
}
}
I use Spring: getHibernateTemplate().saveOrUpdate(item);
Full stack trace of any exception that occurs:No exception is occuring.
Name and version of the database you are using:MySQL 5.0.16
The generated SQL (show_sql=true):Code:
Hibernate:
insert
into
item
(name, id)
values
(?, ?)
Hibernate:
insert
into
item
(name, id)
values
(?, ?)
Debug level Hibernate log excerpt:Code:
2005-12-28 20:15:51,698 INFO [main] org.hibernate.cfg.Environment - Hibernate 3.1
2005-12-28 20:15:51,708 INFO [main] org.hibernate.cfg.Environment - hibernate.properties not found
2005-12-28 20:15:51,718 INFO [main] org.hibernate.cfg.Environment - using CGLIB reflection optimizer
2005-12-28 20:15:51,718 INFO [main] org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
2005-12-28 20:15:51,968 DEBUG [main] org.hibernate.util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd in classpath under org/hibernate/
2005-12-28 20:15:51,968 DEBUG [main] org.hibernate.util.DTDEntityResolver - found http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd in classpath
2005-12-28 20:15:52,259 INFO [main] org.hibernate.cfg.HbmBinder - Mapping class: com.company.Item -> item
2005-12-28 20:15:52,269 DEBUG [main] org.hibernate.cfg.HbmBinder - Mapped property: id -> id
2005-12-28 20:15:52,279 DEBUG [main] org.hibernate.cfg.HbmBinder - Mapped property: name -> name
2005-12-28 20:15:52,389 DEBUG [main] org.hibernate.cfg.HbmBinder - Mapped property: item -> item_id
2005-12-28 20:15:52,399 DEBUG [main] org.hibernate.cfg.HbmBinder - Mapped property: items
2005-12-28 20:15:52,399 DEBUG [main] org.hibernate.cfg.Configuration - Preparing to build session factory with filters : {}
2005-12-28 20:15:52,399 INFO [main] org.hibernate.cfg.Configuration - processing extends queue
2005-12-28 20:15:52,399 INFO [main] org.hibernate.cfg.Configuration - processing collection mappings
2005-12-28 20:15:52,399 DEBUG [main] org.hibernate.cfg.CollectionSecondPass - Second pass for collection: com.company.Item.items
2005-12-28 20:15:52,409 INFO [main] org.hibernate.cfg.HbmBinder - Mapping collection: com.company.Item.items -> item
2005-12-28 20:15:52,409 DEBUG [main] org.hibernate.cfg.CollectionSecondPass - Mapped collection key: item_id, index: sequence, one-to-many: com.company.Item
2005-12-28 20:15:52,409 INFO [main] org.hibernate.cfg.Configuration - processing association property references
2005-12-28 20:15:52,409 INFO [main] org.hibernate.cfg.Configuration - processing foreign key constraints
2005-12-28 20:15:52,409 DEBUG [main] org.hibernate.cfg.Configuration - resolving reference to class: com.company.Item
2005-12-28 20:15:52,439 INFO [main] org.hibernate.connection.ConnectionProviderFactory - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
2005-12-28 20:15:53,180 INFO [main] org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 5.0.16-nt
2005-12-28 20:15:53,180 INFO [main] org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.12 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
2005-12-28 20:15:53,200 INFO [main] org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
2005-12-28 20:15:53,210 INFO [main] org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
2005-12-28 20:15:53,210 INFO [main] org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
2005-12-28 20:15:53,210 INFO [main] org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
2005-12-28 20:15:53,210 INFO [main] org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
2005-12-28 20:15:53,210 INFO [main] org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
2005-12-28 20:15:53,210 INFO [main] org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
2005-12-28 20:15:53,210 INFO [main] org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
2005-12-28 20:15:53,210 DEBUG [main] org.hibernate.cfg.SettingsFactory - Wrap result sets: disabled
2005-12-28 20:15:53,210 INFO [main] org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
2005-12-28 20:15:53,210 INFO [main] org.hibernate.cfg.SettingsFactory - Connection release mode: on_close
2005-12-28 20:15:53,210 INFO [main] org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
2005-12-28 20:15:53,210 INFO [main] org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
2005-12-28 20:15:53,210 INFO [main] org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
2005-12-28 20:15:53,210 INFO [main] org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
2005-12-28 20:15:53,210 INFO [main] org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
2005-12-28 20:15:53,220 INFO [main] org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
2005-12-28 20:15:53,220 INFO [main] org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
2005-12-28 20:15:53,220 INFO [main] org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
2005-12-28 20:15:53,220 INFO [main] org.hibernate.cfg.SettingsFactory - Query cache: disabled
2005-12-28 20:15:53,220 INFO [main] org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.EhCacheProvider
2005-12-28 20:15:53,240 INFO [main] org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
2005-12-28 20:15:53,240 INFO [main] org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
2005-12-28 20:15:53,240 DEBUG [main] org.hibernate.exception.SQLExceptionConverterFactory - Using dialect defined converter
2005-12-28 20:15:53,240 INFO [main] org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
2005-12-28 20:15:53,240 INFO [main] org.hibernate.cfg.SettingsFactory - Statistics: disabled
2005-12-28 20:15:53,240 INFO [main] org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
2005-12-28 20:15:53,240 INFO [main] org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
2005-12-28 20:15:53,330 INFO [main] org.hibernate.impl.SessionFactoryImpl - building session factory
2005-12-28 20:15:53,350 DEBUG [main] org.hibernate.impl.SessionFactoryImpl - Session factory constructed with filter configurations : {}
2005-12-28 20:15:53,360 DEBUG [main] org.hibernate.impl.SessionFactoryImpl - instantiating session factory with properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\opt\jdk1.5.0\jre\bin, java.vm.version=1.5.0-b64, 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.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=c:\opt\eclipse-3.1\workspace\hibernate-example, java.runtime.version=1.5.0-b64, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\opt\jdk1.5.0\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\WARREN~1.GAV\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.jnu.encoding=Cp1252, java.library.path=C:\opt\jdk1.5.0\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\oracle\product\10.1.0\db\bin;C:\oracle\product\10.1.0\db\jre\1.4.2\bin\client;C:\oracle\product\10.1.0\db\jre\1.4.2\bin;C:\opt\perl\bin\;C:\Program Files\Compaq\Compaq Management Agents\Dmi\Win32\Bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\program files\winzip;c:\data\notes;c:\program files\notes;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Common Files\Roxio Shared\DLLShared;C:\PROGRA~1\ATT\Graphviz\bin;C:\PROGRA~1\ATT\Graphviz\bin\tools;;C:\Program Files\Common Files\GTK\2.0\bin;C:\Program Files\Support Tools\;C:\Program Files\MySQL\MySQL Server 5.0\bin;C:\opt\j2sdk1.4.2_05\bin;C:\usr\local\bin;C:\usr\local\wbin;C:\bin;C:\Program Files\Remedy;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE;C:\opt\svn-win32-1.1.0-rc2\bin;c:\usr\bin;c:\opt\bind;c:\opt\openim-1.2.1-bin\bin;c:\opt\merlin\bin, java.specification.name=Java Platform API Specification, java.class.version=49.0, sun.management.compiler=HotSpot Client Compiler, os.version=5.1, user.home=C:\Documents and Settings\warren.gavin, user.timezone=America/Chicago, hibernate.connection.release_mode=on_close, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.5, hibernate.format_sql=true, java.class.path=C:\opt\eclipse-3.1\workspace\hibernate-example-contrib\mysql-connector-java-3.1.12\mysql-connector-java-3.1.12-bin.jar;C:\opt\eclipse-3.1\workspace\hibernate-example-contrib\hibernate-3.1\hibernate3.jar;C:\opt\eclipse-3.1\workspace\hibernate-example-contrib\spring-framework-1.2.6\dist\spring.jar;C:\opt\eclipse-3.1\workspace\hibernate-example-contrib\spring-framework-1.2.6\lib\cglib\cglib-nodep-2.1_3.jar;C:\opt\eclipse-3.1\workspace\hibernate-example-contrib\spring-framework-1.2.6\lib\dom4j\dom4j-1.6.jar;C:\opt\eclipse-3.1\workspace\hibernate-example-contrib\spring-framework-1.2.6\lib\ehcache\ehcache-1.1.jar;C:\opt\eclipse-3.1\workspace\hibernate-example-contrib\spring-framework-1.2.6\lib\log4j\log4j-1.2.9.jar;C:\opt\eclipse-3.1\workspace\hibernate-example-contrib\spring-framework-1.2.6\lib\dom4j\jaxen-1.1-beta-4.jar;C:\opt\eclipse-3.1\workspace\hibernate-example-contrib\spring-framework-1.2.6\lib\jakarta-commons\commons-collections.jar;C:\opt\eclipse-3.1\workspace\hibernate-example-contrib\spring-framework-1.2.6\lib\jakarta-commons\commons-dbcp.jar;C:\opt\eclipse-3.1\workspace\hibernate-example-contrib\spring-framework-1.2.6\lib\jakarta-commons\commons-logging.jar;C:\opt\eclipse-3.1\workspace\hibernate-example-contrib\spring-framework-1.2.6\lib\jakarta-commons\commons-pool.jar;c:\opt\eclipse-3.1\workspace\hibernate-example\bin;C:\opt\eclipse-3.1\workspace\hibernate-example-contrib\spring-framework-1.2.6\lib\j2ee\jta.jar, user.name=warren.gavin, hibernate.show_sql=true, java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=C:\opt\jdk1.5.0\jre, 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, hibernate.cglib.use_reflection_optimizer=true, java.version=1.5.0, java.ext.dirs=C:\opt\jdk1.5.0\jre\lib\ext, sun.boot.class.path=C:\opt\jdk1.5.0\jre\lib\rt.jar;C:\opt\jdk1.5.0\jre\lib\i18n.jar;C:\opt\jdk1.5.0\jre\lib\sunrsasign.jar;C:\opt\jdk1.5.0\jre\lib\jsse.jar;C:\opt\jdk1.5.0\jre\lib\jce.jar;C:\opt\jdk1.5.0\jre\lib\charsets.jar;C:\opt\jdk1.5.0\jre\classes, java.vendor=Sun Microsystems Inc., file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, hibernate.connection.provider_class=org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider, 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}
2005-12-28 20:15:53,771 DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Static SQL for entity: com.company.Item
2005-12-28 20:15:53,771 DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Version select: select id from item where id =?
2005-12-28 20:15:53,771 DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Snapshot select: select item_.id, item_.name as name0_ from item item_ where item_.id=?
2005-12-28 20:15:53,771 DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Insert 0: insert into item (name, id) values (?, ?)
2005-12-28 20:15:53,771 DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Update 0: update item set name=? where id=?
2005-12-28 20:15:53,771 DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Delete 0: delete from item where id=?
2005-12-28 20:15:53,781 DEBUG [main] org.hibernate.persister.collection.AbstractCollectionPersister - Static SQL for collection: com.company.Item.items
2005-12-28 20:15:53,781 DEBUG [main] org.hibernate.persister.collection.AbstractCollectionPersister - Row insert: update item set item_id=?, sequence=? where id=?
2005-12-28 20:15:53,781 DEBUG [main] org.hibernate.persister.collection.AbstractCollectionPersister - Row delete: update item set item_id=null, sequence=null where item_id=? and id=?
2005-12-28 20:15:53,791 DEBUG [main] org.hibernate.persister.collection.AbstractCollectionPersister - One-shot delete: update item set item_id=null, sequence=null where item_id=?
2005-12-28 20:15:53,821 DEBUG [main] org.hibernate.loader.entity.EntityLoader - Static select for entity com.company.Item: select item0_.id as id0_0_, item0_.name as name0_0_, item0_.item_id as item3_0_0_ from item item0_ where item0_.id=?
2005-12-28 20:15:53,821 DEBUG [main] org.hibernate.loader.entity.EntityLoader - Static select for entity com.company.Item: select item0_.id as id0_0_, item0_.name as name0_0_, item0_.item_id as item3_0_0_ from item item0_ where item0_.id=?
2005-12-28 20:15:53,821 DEBUG [main] org.hibernate.loader.entity.EntityLoader - Static select for entity com.company.Item: select item0_.id as id0_0_, item0_.name as name0_0_, item0_.item_id as item3_0_0_ from item item0_ where item0_.id=? for update
2005-12-28 20:15:53,821 DEBUG [main] org.hibernate.loader.entity.EntityLoader - Static select for entity com.company.Item: select item0_.id as id0_0_, item0_.name as name0_0_, item0_.item_id as item3_0_0_ from item item0_ where item0_.id=? for update
2005-12-28 20:15:53,831 DEBUG [main] org.hibernate.loader.entity.EntityLoader - Static select for action ACTION_MERGE on entity com.company.Item: select item0_.id as id0_1_, item0_.name as name0_1_, item0_.item_id as item3_0_1_, items1_.item_id as item3_3_, items1_.id as id3_, items1_.sequence as sequence3_, items1_.id as id0_0_, items1_.name as name0_0_, items1_.item_id as item3_0_0_ from item item0_ left outer join item items1_ on item0_.id=items1_.item_id where item0_.id=?
2005-12-28 20:15:53,831 DEBUG [main] org.hibernate.loader.entity.EntityLoader - Static select for action ACTION_REFRESH on entity com.company.Item: select item0_.id as id0_1_, item0_.name as name0_1_, item0_.item_id as item3_0_1_, items1_.item_id as item3_3_, items1_.id as id3_, items1_.sequence as sequence3_, items1_.id as id0_0_, items1_.name as name0_0_, items1_.item_id as item3_0_0_ from item item0_ left outer join item items1_ on item0_.id=items1_.item_id where item0_.id=?
2005-12-28 20:15:53,841 DEBUG [main] org.hibernate.loader.collection.OneToManyLoader - Static select for one-to-many com.company.Item.items: select items0_.item_id as item3_1_, items0_.id as id1_, items0_.sequence as sequence1_, items0_.id as id0_0_, items0_.name as name0_0_, items0_.item_id as item3_0_0_ from item items0_ where items0_.item_id=?
2005-12-28 20:15:53,841 DEBUG [main] org.hibernate.impl.SessionFactoryObjectFactory - initializing class SessionFactoryObjectFactory
2005-12-28 20:15:53,851 DEBUG [main] org.hibernate.impl.SessionFactoryObjectFactory - registered: 40288fe508744cc00108744cc2f10000 (unnamed)
2005-12-28 20:15:53,851 INFO [main] org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
2005-12-28 20:15:53,851 DEBUG [main] org.hibernate.impl.SessionFactoryImpl - instantiated session factory
2005-12-28 20:15:53,851 INFO [main] org.hibernate.impl.SessionFactoryImpl - Checking 0 named HQL queries
2005-12-28 20:15:53,851 INFO [main] org.hibernate.impl.SessionFactoryImpl - Checking 0 named SQL queries
2005-12-28 20:15:54,101 DEBUG [main] org.hibernate.impl.SessionImpl - opened session at timestamp: 4652329181433856
2005-12-28 20:15:54,101 DEBUG [main] org.hibernate.jdbc.ConnectionManager - opening JDBC connection
2005-12-28 20:15:54,111 DEBUG [main] org.hibernate.transaction.JDBCTransaction - begin
2005-12-28 20:15:54,111 DEBUG [main] org.hibernate.transaction.JDBCTransaction - current autocommit status: true
2005-12-28 20:15:54,111 DEBUG [main] org.hibernate.transaction.JDBCTransaction - disabling autocommit
2005-12-28 20:15:54,111 DEBUG [main] org.hibernate.jdbc.JDBCContext - after transaction begin
2005-12-28 20:15:54,191 DEBUG [main] org.hibernate.event.def.AbstractSaveEventListener - transient instance of: com.company.Item
2005-12-28 20:15:54,191 DEBUG [main] org.hibernate.event.def.DefaultSaveOrUpdateEventListener - saving transient instance
2005-12-28 20:15:54,191 DEBUG [main] org.hibernate.event.def.AbstractSaveEventListener - generated identifier: 40288fe508744cc00108744cc44f0001, using strategy: org.hibernate.id.UUIDHexGenerator
2005-12-28 20:15:54,191 DEBUG [main] org.hibernate.event.def.AbstractSaveEventListener - saving [com.company.Item#40288fe508744cc00108744cc44f0001]
2005-12-28 20:15:54,201 DEBUG [main] org.hibernate.engine.Cascade - processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,201 DEBUG [main] org.hibernate.engine.Cascade - done processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,241 DEBUG [main] org.hibernate.engine.Cascade - processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,241 DEBUG [main] org.hibernate.engine.Cascade - done processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,241 DEBUG [main] org.hibernate.transaction.JDBCTransaction - commit
2005-12-28 20:15:54,241 DEBUG [main] org.hibernate.impl.SessionImpl - automatically flushing session
2005-12-28 20:15:54,241 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - flushing session
2005-12-28 20:15:54,241 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades
2005-12-28 20:15:54,241 DEBUG [main] org.hibernate.engine.Cascade - processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,241 DEBUG [main] org.hibernate.engine.Cascade - done processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,241 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
2005-12-28 20:15:54,241 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections
2005-12-28 20:15:54,272 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections
2005-12-28 20:15:54,272 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates
2005-12-28 20:15:54,272 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
2005-12-28 20:15:54,272 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2005-12-28 20:15:54,272 DEBUG [main] org.hibernate.pretty.Printer - listing entities:
2005-12-28 20:15:54,272 DEBUG [main] org.hibernate.pretty.Printer - com.company.Item{item=null, items=null, name=test, id=40288fe508744cc00108744cc44f0001}
2005-12-28 20:15:54,272 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - executing flush
2005-12-28 20:15:54,272 DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Inserting entity: [com.company.Item#40288fe508744cc00108744cc44f0001]
2005-12-28 20:15:54,272 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-12-28 20:15:54,282 DEBUG [main] org.hibernate.SQL -
insert
into
item
(name, id)
values
(?, ?)
Hibernate:
insert
into
item
(name, id)
values
(?, ?)
2005-12-28 20:15:54,282 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - preparing statement
2005-12-28 20:15:54,302 DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Dehydrating entity: [com.company.Item#40288fe508744cc00108744cc44f0001]
2005-12-28 20:15:54,302 DEBUG [main] org.hibernate.type.StringType - binding 'test' to parameter: 1
2005-12-28 20:15:54,302 DEBUG [main] org.hibernate.type.StringType - binding '40288fe508744cc00108744cc44f0001' to parameter: 2
2005-12-28 20:15:54,302 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - Adding to batch
2005-12-28 20:15:54,302 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - Executing batch size: 1
2005-12-28 20:15:54,302 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-12-28 20:15:54,302 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - closing statement
2005-12-28 20:15:54,302 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - post flush
2005-12-28 20:15:54,302 DEBUG [main] org.hibernate.jdbc.JDBCContext - before transaction completion
2005-12-28 20:15:54,302 DEBUG [main] org.hibernate.impl.SessionImpl - before transaction completion
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.transaction.JDBCTransaction - re-enabling autocommit
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.transaction.JDBCTransaction - committed JDBC Connection
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.jdbc.JDBCContext - after transaction completion
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.impl.SessionImpl - after transaction completion
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.impl.SessionImpl - closing session
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.jdbc.ConnectionManager - performing cleanup
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.jdbc.ConnectionManager - closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.jdbc.JDBCContext - after transaction completion
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.impl.SessionImpl - after transaction completion
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.impl.SessionImpl - opened session at timestamp: 4652329182666752
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.jdbc.ConnectionManager - opening JDBC connection
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.transaction.JDBCTransaction - begin
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.transaction.JDBCTransaction - current autocommit status: true
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.transaction.JDBCTransaction - disabling autocommit
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.jdbc.JDBCContext - after transaction begin
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.engine.IdentifierValue - id unsaved-value strategy NULL
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.event.def.AbstractSaveEventListener - detached instance of: com.company.Item
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.event.def.DefaultSaveOrUpdateEventListener - updating detached instance
2005-12-28 20:15:54,362 DEBUG [main] org.hibernate.event.def.DefaultSaveOrUpdateEventListener - updating [com.company.Item#40288fe508744cc00108744cc44f0001]
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.event.def.ReattachVisitor - collection dereferenced while transient [com.company.Item.items#40288fe508744cc00108744cc44f0001]
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.event.def.DefaultSaveOrUpdateEventListener - updating [com.company.Item#40288fe508744cc00108744cc44f0001]
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.Cascade - processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.Cascade - cascade ACTION_SAVE_UPDATE for collection: com.company.Item.items
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.CascadingAction - cascading to saveOrUpdate: com.company.Item
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.event.def.AbstractSaveEventListener - transient instance of: com.company.Item
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.event.def.DefaultSaveOrUpdateEventListener - saving transient instance
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.event.def.AbstractSaveEventListener - generated identifier: 40288fe508744cc00108744cc5040002, using strategy: org.hibernate.id.UUIDHexGenerator
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.event.def.AbstractSaveEventListener - saving [com.company.Item#40288fe508744cc00108744cc5040002]
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.Cascade - processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.Cascade - done processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.Cascade - processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.Cascade - done processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.Cascade - done cascade ACTION_SAVE_UPDATE for collection: com.company.Item.items
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.Cascade - done processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.transaction.JDBCTransaction - commit
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.impl.SessionImpl - automatically flushing session
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - flushing session
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.Cascade - processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.Cascade - cascade ACTION_SAVE_UPDATE for collection: com.company.Item.items
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.CascadingAction - cascading to saveOrUpdate: com.company.Item
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.event.def.AbstractSaveEventListener - persistent instance of: com.company.Item
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.event.def.DefaultSaveOrUpdateEventListener - ignoring persistent instance
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.event.def.DefaultSaveOrUpdateEventListener - object already associated with session: [com.company.Item#40288fe508744cc00108744cc5040002]
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.Cascade - done cascade ACTION_SAVE_UPDATE for collection: com.company.Item.items
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.Cascade - done processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.Cascade - processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.engine.Cascade - done processing cascade ACTION_SAVE_UPDATE for: com.company.Item
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
2005-12-28 20:15:54,372 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections
2005-12-28 20:15:54,412 DEBUG [main] org.hibernate.event.def.WrapVisitor - Wrapped collection in role: com.company.Item.items
2005-12-28 20:15:54,412 DEBUG [main] org.hibernate.event.def.DefaultFlushEntityEventListener - Updating entity: [com.company.Item#40288fe508744cc00108744cc44f0001]
2005-12-28 20:15:54,412 DEBUG [main] org.hibernate.engine.Collections - Collection found: [com.company.Item.items#40288fe508744cc00108744cc44f0001], was: [<unreferenced>] (initialized)
2005-12-28 20:15:54,412 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections
2005-12-28 20:15:54,412 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates
2005-12-28 20:15:54,412 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 1 insertions, 1 updates, 0 deletions to 2 objects
2005-12-28 20:15:54,412 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 1 (re)creations, 0 updates, 1 removals to 1 collections
2005-12-28 20:15:54,412 DEBUG [main] org.hibernate.pretty.Printer - listing entities:
2005-12-28 20:15:54,412 DEBUG [main] org.hibernate.pretty.Printer - com.company.Item{item=null, items=[com.company.Item#40288fe508744cc00108744cc5040002], name=test, id=40288fe508744cc00108744cc44f0001}
2005-12-28 20:15:54,412 DEBUG [main] org.hibernate.pretty.Printer - com.company.Item{item=com.company.Item#40288fe508744cc00108744cc44f0001, items=null, name=test sub, id=40288fe508744cc00108744cc5040002}
2005-12-28 20:15:54,412 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - executing flush
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Inserting entity: [com.company.Item#40288fe508744cc00108744cc5040002]
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.SQL -
insert
into
item
(name, id)
values
(?, ?)
Hibernate:
insert
into
item
(name, id)
values
(?, ?)
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - preparing statement
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Dehydrating entity: [com.company.Item#40288fe508744cc00108744cc5040002]
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.type.StringType - binding 'test sub' to parameter: 1
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.type.StringType - binding '40288fe508744cc00108744cc5040002' to parameter: 2
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - Adding to batch
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - Executing batch size: 1
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - closing statement
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Updating entity: [com.company.Item#40288fe508744cc00108744cc44f0001]
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.SQL -
update
item
set
name=?
where
id=?
Hibernate:
update
item
set
name=?
where
id=?
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - preparing statement
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Dehydrating entity: [com.company.Item#40288fe508744cc00108744cc44f0001]
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.type.StringType - binding 'test' to parameter: 1
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.type.StringType - binding '40288fe508744cc00108744cc44f0001' to parameter: 2
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - Adding to batch
2005-12-28 20:15:54,422 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - Executing batch size: 1
2005-12-28 20:15:54,452 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-12-28 20:15:54,452 DEBUG [main] org.hibernate.jdbc.AbstractBatcher - closing statement
2005-12-28 20:15:54,452 DEBUG [main] org.hibernate.event.def.AbstractFlushingEventListener - post flush
2005-12-28 20:15:54,462 DEBUG [main] org.hibernate.jdbc.JDBCContext - before transaction completion
2005-12-28 20:15:54,462 DEBUG [main] org.hibernate.impl.SessionImpl - before transaction completion
2005-12-28 20:15:54,502 DEBUG [main] org.hibernate.transaction.JDBCTransaction - re-enabling autocommit
2005-12-28 20:15:54,502 DEBUG [main] org.hibernate.transaction.JDBCTransaction - committed JDBC Connection
2005-12-28 20:15:54,502 DEBUG [main] org.hibernate.jdbc.JDBCContext - after transaction completion
2005-12-28 20:15:54,502 DEBUG [main] org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
2005-12-28 20:15:54,502 DEBUG [main] org.hibernate.impl.SessionImpl - after transaction completion
2005-12-28 20:15:54,502 DEBUG [main] org.hibernate.impl.SessionImpl - closing session
2005-12-28 20:15:54,502 DEBUG [main] org.hibernate.jdbc.ConnectionManager - performing cleanup
2005-12-28 20:15:54,502 DEBUG [main] org.hibernate.jdbc.ConnectionManager - closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2005-12-28 20:15:54,502 DEBUG [main] org.hibernate.jdbc.JDBCContext - after transaction completion
2005-12-28 20:15:54,502 DEBUG [main] org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
2005-12-28 20:15:54,502 DEBUG [main] org.hibernate.impl.SessionImpl - after transaction completion
SQL to create table:Code:
DROP TABLE IF EXISTS item;
CREATE TABLE item (
id CHAR(32) NOT NULL,
item_id char(32),
sequence INT,
name VARCHAR(255) NOT NULL,
PRIMARY KEY (id),
KEY ix_item_item (item_id),
KEY ix_item_sequence (sequence),
CONSTRAINT fk_item_item
FOREIGN KEY (item_id) REFERENCES item (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Data in the item table:Code:
id item_id sequence name
40288fe508743a3e0108743a43940001 <NULL> <NULL> test
40288fe508743a3e0108743a44480002 <NULL> <NULL> test sub