bruehlicke wrote:
The property-ref gives me an option to map many-to-one for non primary keys - great. ...
B
i have been trying to get this (property-ref) to work for a week on mysql 4.0.18. reversing always gets us a null set when the dba guy makes up the tables and populates them. using hbm2java gives us an empty set after we add the property-ref to the hbm file.
trying to to go forward into the *test* database from java using hbm2ddl does the same thing.
can anyone point me to a simple parent and child .java and .hbm.xml files that work using a property-ref i.e. the foreign key in the child (many) table is not the primay key of the parent table (one)?
i can not get the simple code below to work (which uses hbm2ddl).
any pointers will be appreciated.
thanks
java, hbm files, and output going forward:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="hex.Parent">
<id name="id" type="int">
<generator class="assigned" />
</id>
<property name="value" type="java.lang.String" unique="true" not-null="true" length="20"/>
<!-- associations -->
<!-- bi-directional one-to-many association to Child -->
<set name="childs" lazy="true" inverse="true">
<key column="parent"/>
<one-to-many class="hex.Child"/>
</set>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="hex.Child">
<id name="id" type="int">
<generator class="assigned"/>
</id>
<property name="value" type="java.lang.String" not-null="true" length="20"/>
<!-- associations -->
<!-- bi-directional many-to-one association to Parent -->
<many-to-one name="parent" property-ref="value" not-null="true"/>
</class>
</hibernate-mapping>
package hex;
import java.io.Serializable;
import java.util.Set;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
public class Parent implements Serializable {
private Integer id;
private String value;
private Set childs;
public Parent(Integer key, String value, Set childs) {
this.id= key;
this.value= value;
this.childs= childs;
}
public Parent() {}
public Integer getId() {
return this.id;
}
public void setId(Integer key) {
this.id= key;
}
public String getValue() {
return this.value;
}
public void setValue(String value) {
this.value= value;
}
public Set getChilds() {
return this.childs;
}
public void setChilds(Set childs) {
this.childs= childs;
}
public String toString() {
return new ToStringBuilder(this).append("id", getId()).toString();
}
public boolean equals(Object other) {
if (!(other instanceof Parent))
return false;
Parent castOther= (Parent)other;
return new EqualsBuilder().append(this.getId(), castOther.getId()).isEquals();
}
public int hashCode() {
return new HashCodeBuilder().append(getId()).toHashCode();
}
}
package hex;
import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
public class Child implements Serializable {
private Integer id;
private String value;
private Parent parent;
public Child(Integer key, String value, Parent parent) {
this.id= key;
this.value= value;
this.parent= parent;
}
public Child() {}
public Integer getId() {
return this.id;
}
public void setId(Integer key) {
this.id=key;
}
public String getValue() {
return this.value;
}
public void setValue(String value) {
this.value= value;
}
public Parent getParent() {
return this.parent;
}
public void setParent(Parent parent) {
this.parent= parent;
}
public String toString() {
return new ToStringBuilder(this).append("id", getId()).toString();
}
public boolean equals(Object other) {
if (!(other instanceof Child))
return false;
Child castOther= (Child)other;
return new EqualsBuilder().append(this.getId(),castOther.getId()).isEquals();
}
public int hashCode() {
return new HashCodeBuilder().append(getId()).toHashCode();
}
}
import java.util.*;
import net.sf.hibernate.*;
import net.sf.hibernate.cfg.*;
import org.apache.log4j.*;
import hex.*;
public class Main {
Main(final Configuration cfg,final SessionFactory factory) {
this.cfg=cfg;
this.factory=factory;
}
Main() throws Exception {
cfg= new Configuration().addClass(Parent.class).addClass(Child.class);
cfg.setProperty(Environment.HBM2DDL_AUTO, "create");
//cfg.setProperty("hibernate.show_sql", "true");
factory= cfg.buildSessionFactory();
}
void createTables() throws Exception {
System.out.println("Setting up some test data");
Session s= factory.openSession();
Transaction tx= s.beginTransaction();
Parent p1=new Parent(new Integer(1),"p1",new HashSet());
Child c1=new Child(new Integer(1),"c1 of p1",p1);
Child c2=new Child(new Integer(2),"c2 of p1",p1);
p1.getChilds().add(c1);
p1.getChilds().add(c2);
s.save(p1);
s.save(c1);
s.save(c2);
tx.commit();
s.close();
s= factory.openSession();
tx = s.beginTransaction();
p1 = (Parent)s.load(Parent.class,p1.getId());
logger.info("Parent: " + p1.getId() + ", " + p1.getChilds());
c1 = (Child)s.load(Child.class,c2.getId());
logger.info("Child: " + c1.getId());
Set childs=p1.getChilds();
for(Iterator i=childs.iterator();i.hasNext();) {
Child c=(Child)i.next();
logger.info("c="+c);
}
tx.commit();
s.close();
}
void run() throws Exception {
createTables();
}
private final Configuration cfg;
private final SessionFactory factory;
public static void main(String[] args) throws Exception {
logger.info("start");
final Main main= new Main();
logger.info("constructed");
main.run();
logger.info("close sf");
main.factory.close();
}
private static final Logger logger= Logger.getLogger(Main.class);
{
logger.setLevel(Level.INFO);
}
}
16:46:44,062 INFO Main:54 - start
16:46:44,218 INFO Environment:462 - Hibernate 2.1.2
16:46:44,250 INFO Environment:496 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.gjt.mm.mysql.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.hibernate.cache.HashtableCacheProvider, hibernate.cache.use_query_cache=true, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=root, hibernate.connection.url=jdbc:mysql://204.1.213.186:3306/test, hibernate.show_sql=true, hibernate.connection.password=, hibernate.connection.pool_size=1}
16:46:44,250 INFO Environment:518 - using java.io streams to persist binary types
16:46:44,250 INFO Environment:519 - using CGLIB reflection optimizer
16:46:44,281 INFO Configuration:329 - Mapping resource: hex/Parent.hbm.xml
16:46:44,484 DEBUG DTDEntityResolver:20 - trying to locate
http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath under net/sf/hibernate/
16:46:44,500 DEBUG DTDEntityResolver:29 - found
http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath
16:46:44,906 INFO Binder:229 - Mapping class: hex.Parent -> Parent
16:46:45,156 DEBUG Binder:462 - Mapped property: id -> id, type: integer
16:46:45,187 DEBUG Binder:462 - Mapped property: value -> value, type: string
16:46:45,265 DEBUG Binder:462 - Mapped property: childs, type: java.util.Set
16:46:45,265 INFO Configuration:329 - Mapping resource: hex/Child.hbm.xml
16:46:45,281 DEBUG DTDEntityResolver:20 - trying to locate
http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath under net/sf/hibernate/
16:46:45,281 DEBUG DTDEntityResolver:29 - found
http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath
16:46:45,312 INFO Binder:229 - Mapping class: hex.Child -> Child
16:46:45,312 DEBUG Binder:462 - Mapped property: id -> id, type: integer
16:46:45,312 DEBUG Binder:462 - Mapped property: value -> value, type: string
16:46:45,328 DEBUG Binder:462 - Mapped property: parent -> parent, type: hex.Parent
16:46:45,328 INFO Configuration:595 - processing one-to-many association mappings
16:46:45,328 DEBUG Binder:1326 - Second pass for collection: hex.Parent.childs
16:46:45,328 INFO Binder:1154 - Mapping collection: hex.Parent.childs -> Child
16:46:45,328 DEBUG Binder:1341 - Mapped collection key: parent, one-to-many: hex.Child
16:46:45,328 INFO Configuration:604 - processing one-to-one association property references
16:46:45,343 INFO Configuration:629 - processing foreign key constraints
16:46:45,421 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
16:46:45,421 INFO SettingsFactory:58 - Maximim outer join fetch depth: 1
16:46:45,421 INFO SettingsFactory:62 - Use outer join fetching: true
16:46:45,437 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
16:46:45,437 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
16:46:45,468 INFO DriverManagerConnectionProvider:71 - using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://204.1.213.186:3306/test
16:46:45,468 INFO DriverManagerConnectionProvider:72 - connection properties: {user=root, password=}
16:46:45,484 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
16:46:45,500 DEBUG DriverManagerConnectionProvider:78 - total checked-out connections: 0
16:46:45,500 DEBUG DriverManagerConnectionProvider:94 - opening new JDBC connection
16:46:45,843 DEBUG DriverManagerConnectionProvider:100 - created connection to: jdbc:mysql://204.1.213.186:3306/test, Isolation Level: 4
16:46:45,859 DEBUG DriverManagerConnectionProvider:114 - returning connection to pool, pool size: 1
16:46:45,859 INFO SettingsFactory:102 - Use scrollable result sets: true
16:46:45,859 INFO SettingsFactory:105 - Use JDBC3 getGeneratedKeys(): true
16:46:45,859 INFO SettingsFactory:108 - Optimize cache for minimal puts: false
16:46:45,859 INFO SettingsFactory:114 - echoing all SQL to stdout
16:46:45,859 INFO SettingsFactory:117 - Query language substitutions: {no='N', true=1, yes='Y', false=0}
16:46:45,859 INFO SettingsFactory:128 - cache provider: net.sf.hibernate.cache.HashtableCacheProvider
16:46:45,875 INFO Configuration:1080 - instantiating and configuring caches
16:46:46,281 INFO SessionFactoryImpl:119 - building session factory
16:46:46,281 DEBUG SessionFactoryImpl:125 - instantiating session factory with properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, hibernate.connection.password=, hibernate.cache.provider_class=net.sf.hibernate.cache.HashtableCacheProvider, sun.boot.library.path=C:\Program Files\Java\j2re1.4.2_03\bin, java.vm.version=1.4.2_03-b02, hibernate.proxool.pool_alias=pool1, hibernate.connection.username=root, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, hibernate.cache.use_query_cache=true, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=US, sun.os.patch.level=Service Pack 1, java.vm.specification.name=Java Virtual Machine Specification, user.dir=U:\projects\hex, java.runtime.version=1.4.2_03-b02, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\Program Files\Java\j2re1.4.2_03\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\rtayek\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.java2d.fontpath=, java.library.path=C:\Program Files\Java\j2re1.4.2_03\bin;.;C:\WINDOWS\System32;C:\WINDOWS;u:\bin, java.specification.name=Java Platform API Specification, java.class.version=48.0, hibernate.connection.pool_size=1, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, os.version=5.1, user.home=C:\Documents and Settings\rtayek, user.timezone=America/Los_Angeles, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.4, hibernate.connection.driver_class=org.gjt.mm.mysql.Driver, java.class.path=U:\projects\hex\bin;U:\projects\hex\lib\hibernate2.jar;U:\projects\hex\lib\cglib-2.0-rc2.jar;U:\projects\hex\lib\commons-collections-2.1.jar;U:\projects\hex\lib\commons-lang-1.0.1.jar;U:\projects\hex\lib\commons-logging-1.0.3.jar;U:\projects\hex\lib\dom4j-1.4.jar;U:\projects\hex\lib\jta.jar;U:\projects\hex\lib\log4j-1.2.8.jar;U:\projects\hex\lib\mysql.jar;U:\projects\hex\lib\odmg-3.0.jar;C:\Program Files\Development\eclipse\plugins\org.junit_3.8.1\junit.jar, user.name=rtayek, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\Program Files\Java\j2re1.4.2_03, sun.arch.data.model=32, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://204.1.213.186:3306/test, user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, hibernate.jdbc.use_streams_for_binary=true, java.version=1.4.2_03, java.ext.dirs=C:\Program Files\Java\j2re1.4.2_03\lib\ext, sun.boot.class.path=C:\Program Files\Java\j2re1.4.2_03\lib\rt.jar;C:\Program Files\Java\j2re1.4.2_03\lib\i18n.jar;C:\Program Files\Java\j2re1.4.2_03\lib\sunrsasign.jar;C:\Program Files\Java\j2re1.4.2_03\lib\jsse.jar;C:\Program Files\Java\j2re1.4.2_03\lib\jce.jar;C:\Program Files\Java\j2re1.4.2_03\lib\charsets.jar;C:\Program Files\Java\j2re1.4.2_03\classes, java.vendor=Sun Microsystems Inc., hibernate.jdbc.batch_size=0, file.separator=\, hibernate.hbm2ddl.auto=create, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, hibernate.max_fetch_depth=1, sun.cpu.isalist=pentium i486 i386}
16:46:47,000 DEBUG SessionFactoryObjectFactory:39 - initializing class SessionFactoryObjectFactory
16:46:47,015 DEBUG SessionFactoryObjectFactory:76 - registered: 4c815534fbc75dd200fbc75dd6580000 (unnamed)
16:46:47,015 INFO SessionFactoryObjectFactory:82 - no JNDI name configured
16:46:47,031 DEBUG SessionFactoryImpl:196 - instantiated session factory
16:46:47,031 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
16:46:47,031 INFO Configuration:595 - processing one-to-many association mappings
16:46:47,031 INFO Configuration:604 - processing one-to-one association property references
16:46:47,031 INFO Configuration:629 - processing foreign key constraints
16:46:47,031 INFO Configuration:595 - processing one-to-many association mappings
16:46:47,046 INFO Configuration:604 - processing one-to-one association property references
16:46:47,046 INFO Configuration:629 - processing foreign key constraints
16:46:47,046 INFO SchemaExport:98 - Running hbm2ddl schema export
16:46:47,046 INFO SchemaExport:117 - exporting generated schema to database
16:46:47,046 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
16:46:47,046 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
16:46:47,046 INFO DriverManagerConnectionProvider:71 - using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://204.1.213.186:3306/test
16:46:47,046 INFO DriverManagerConnectionProvider:72 - connection properties: {user=root, password=}
16:46:47,046 DEBUG DriverManagerConnectionProvider:78 - total checked-out connections: 0
16:46:47,046 DEBUG DriverManagerConnectionProvider:94 - opening new JDBC connection
16:46:47,062 DEBUG DriverManagerConnectionProvider:100 - created connection to: jdbc:mysql://204.1.213.186:3306/test, Isolation Level: 4
16:46:47,078 DEBUG SchemaExport:132 - drop table if exists Parent
16:46:47,078 DEBUG SchemaExport:132 - drop table if exists Child
16:46:47,078 DEBUG SchemaExport:149 - create table Parent (
id INTEGER not null,
value VARCHAR(20) not null unique,
primary key (id)
)
16:46:47,140 DEBUG SchemaExport:149 - create table Child (
id INTEGER not null,
value VARCHAR(20) not null,
parent VARCHAR(255) not null,
primary key (id)
)
16:46:47,218 INFO SchemaExport:160 - schema export complete
16:46:47,250 DEBUG DriverManagerConnectionProvider:114 - returning connection to pool, pool size: 1
16:46:47,250 INFO DriverManagerConnectionProvider:137 - cleaning up connection pool: jdbc:mysql://204.1.213.186:3306/test
16:46:47,250 INFO UpdateTimestampsCache:35 - starting update timestamps cache at region: net.sf.hibernate.cache.UpdateTimestampsCache
16:46:47,265 INFO QueryCache:39 - starting query cache at region: net.sf.hibernate.cache.QueryCache
16:46:47,265 INFO Main:56 - constructed
Setting up some test data
16:46:47,531 DEBUG SessionImpl:531 - opened session
16:46:47,546 DEBUG JDBCTransaction:37 - begin
16:46:47,546 DEBUG DriverManagerConnectionProvider:78 - total checked-out connections: 0
16:46:47,546 DEBUG DriverManagerConnectionProvider:84 - using pooled JDBC connection, pool size: 0
16:46:47,546 DEBUG JDBCTransaction:41 - current autocommit status:false
16:46:47,578 DEBUG SessionImpl:760 - generated identifier: 1
16:46:47,578 DEBUG SessionImpl:807 - saving [hex.Parent#1]
16:46:47,609 DEBUG SessionImpl:760 - generated identifier: 1
16:46:47,609 DEBUG SessionImpl:807 - saving [hex.Child#1]
16:46:47,609 DEBUG SessionImpl:760 - generated identifier: 2
16:46:47,609 DEBUG SessionImpl:807 - saving [hex.Child#2]
16:46:47,609 DEBUG JDBCTransaction:59 - commit
16:46:47,609 DEBUG SessionImpl:2210 - flushing session
16:46:47,609 DEBUG SessionImpl:2403 - Flushing entities and processing referenced collections
16:46:47,640 DEBUG WrapVisitor:76 - Wrapped collection in role: hex.Parent.childs
16:46:47,640 DEBUG SessionImpl:2850 - Collection found: [hex.Parent.childs#1], was: [<unreferenced>]
16:46:47,640 DEBUG SessionImpl:2746 - Processing unreferenced collections
16:46:47,640 DEBUG SessionImpl:2760 - Scheduling collection removes/(re)creates/updates
16:46:47,656 DEBUG SessionImpl:2234 - Flushed: 3 insertions, 0 updates, 0 deletions to 3 objects
16:46:47,656 DEBUG SessionImpl:2239 - Flushed: 1 (re)creations, 0 updates, 0 removals to 1 collections
16:46:47,656 DEBUG Printer:75 - listing entities:
16:46:47,656 DEBUG Printer:82 - hex.Child{value=c1 of p1, parent=Parent#1, id=1}
16:46:47,671 DEBUG Printer:82 - hex.Parent{childs=[Child#1, Child#2], value=p1, id=1}
16:46:47,687 DEBUG Printer:82 - hex.Child{value=c2 of p1, parent=Parent#1, id=2}
16:46:47,687 DEBUG SessionImpl:2323 - executing flush
16:46:47,687 DEBUG EntityPersister:453 - Inserting entity: [hex.Parent#1]
16:46:47,687 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
16:46:47,687 DEBUG SQL:237 - insert into Parent (value, id) values (?, ?)
Hibernate: insert into Parent (value, id) values (?, ?)
16:46:47,687 DEBUG BatcherImpl:241 - preparing statement
16:46:47,718 DEBUG EntityPersister:388 - Dehydrating entity: [hex.Parent#1]
16:46:47,718 DEBUG StringType:46 - binding 'p1' to parameter: 1
16:46:47,718 DEBUG IntegerType:46 - binding '1' to parameter: 2
16:46:47,718 DEBUG EntityPersister:453 - Inserting entity: [hex.Child#1]
16:46:47,718 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
16:46:47,718 DEBUG BatcherImpl:261 - closing statement
16:46:47,718 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
16:46:47,718 DEBUG SQL:237 - insert into Child (value, parent, id) values (?, ?, ?)
Hibernate: insert into Child (value, parent, id) values (?, ?, ?)
16:46:47,734 DEBUG BatcherImpl:241 - preparing statement
16:46:47,734 DEBUG EntityPersister:388 - Dehydrating entity: [hex.Child#1]
16:46:47,734 DEBUG StringType:46 - binding 'c1 of p1' to parameter: 1
16:46:47,734 DEBUG StringType:46 - binding 'p1' to parameter: 2
16:46:47,734 DEBUG IntegerType:46 - binding '1' to parameter: 3
16:46:47,734 DEBUG EntityPersister:453 - Inserting entity: [hex.Child#2]
16:46:47,734 DEBUG EntityPersister:388 - Dehydrating entity: [hex.Child#2]
16:46:47,734 DEBUG StringType:46 - binding 'c2 of p1' to parameter: 1
16:46:47,734 DEBUG StringType:46 - binding 'p1' to parameter: 2
16:46:47,734 DEBUG IntegerType:46 - binding '2' to parameter: 3
16:46:47,734 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
16:46:47,734 DEBUG BatcherImpl:261 - closing statement
16:46:47,734 DEBUG SessionImpl:2790 - post flush
16:46:47,750 DEBUG SessionImpl:561 - transaction completion
16:46:47,750 DEBUG SessionImpl:549 - closing session
16:46:47,750 DEBUG SessionImpl:3294 - disconnecting session
16:46:47,750 DEBUG DriverManagerConnectionProvider:114 - returning connection to pool, pool size: 1
16:46:47,750 DEBUG SessionImpl:561 - transaction completion
16:46:47,750 DEBUG SessionImpl:531 - opened session
16:46:47,750 DEBUG JDBCTransaction:37 - begin
16:46:47,750 DEBUG DriverManagerConnectionProvider:78 - total checked-out connections: 0
16:46:47,750 DEBUG DriverManagerConnectionProvider:84 - using pooled JDBC connection, pool size: 0
16:46:47,750 DEBUG JDBCTransaction:41 - current autocommit status:false
16:46:47,750 DEBUG SessionImpl:1950 - loading [hex.Parent#1]
16:46:47,750 DEBUG SessionImpl:2047 - attempting to resolve [hex.Parent#1]
16:46:47,750 DEBUG SessionImpl:2080 - object not resolved in any cache [hex.Parent#1]
16:46:47,750 DEBUG EntityPersister:416 - Materializing entity: [hex.Parent#1]
16:46:47,765 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
16:46:47,765 DEBUG SQL:237 - select parent0_.id as id0_, parent0_.value as value0_ from Parent parent0_ where parent0_.id=?
Hibernate: select parent0_.id as id0_, parent0_.value as value0_ from Parent parent0_ where parent0_.id=?
16:46:47,765 DEBUG BatcherImpl:241 - preparing statement
16:46:47,765 DEBUG IntegerType:46 - binding '1' to parameter: 1
16:46:47,765 DEBUG Loader:197 - processing result set
16:46:47,765 DEBUG Loader:405 - result row: 1
16:46:47,765 DEBUG Loader:536 - Initializing object from ResultSet: 1
16:46:47,765 DEBUG Loader:605 - Hydrating entity: hex.Parent#1
16:46:47,765 DEBUG StringType:68 - returning 'p1' as column: value0_
16:46:47,781 DEBUG Loader:226 - done processing result set (1 rows)
16:46:47,781 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
16:46:47,781 DEBUG BatcherImpl:261 - closing statement
16:46:47,781 DEBUG Loader:239 - total objects hydrated: 1
16:46:47,781 DEBUG SessionImpl:2166 - resolving associations for [hex.Parent#1]
16:46:47,781 DEBUG SessionImpl:3891 - creating collection wrapper:[hex.Parent.childs#1]
16:46:47,781 DEBUG SessionImpl:2190 - done materializing entity [hex.Parent#1]
16:46:47,796 DEBUG SessionImpl:3082 - initializing non-lazy collections
16:46:47,796 DEBUG SessionImpl:3218 - initializing collection [hex.Parent.childs#1]
16:46:47,796 DEBUG SessionImpl:3219 - checking second-level cache
16:46:47,796 DEBUG SessionImpl:3225 - collection not cached
16:46:47,796 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
16:46:47,796 DEBUG SQL:237 - select childs0_.id as id__, childs0_.parent as parent__, childs0_.id as id0_, childs0_.value as value0_, childs0_.parent as parent0_ from Child childs0_ where childs0_.parent=?
Hibernate: select childs0_.id as id__, childs0_.parent as parent__, childs0_.id as id0_, childs0_.value as value0_, childs0_.parent as parent0_ from Child childs0_ where childs0_.parent=?
16:46:47,796 DEBUG BatcherImpl:241 - preparing statement
16:46:47,796 DEBUG IntegerType:46 - binding '1' to parameter: 1
16:46:47,796 DEBUG Loader:327 - result set contains (possibly empty) collection: [hex.Parent.childs#1]
16:46:47,796 DEBUG SessionImpl:2984 - uninitialized collection: initializing
16:46:47,812 DEBUG Loader:197 - processing result set
16:46:47,812 DEBUG Loader:226 - done processing result set (0 rows)
16:46:47,812 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
16:46:47,812 DEBUG BatcherImpl:261 - closing statement
16:46:47,812 DEBUG Loader:239 - total objects hydrated: 0
16:46:47,812 DEBUG SessionImpl:3043 - 1 collections were found in result set
16:46:47,812 DEBUG SessionImpl:3061 - collection fully initialized: [hex.Parent.childs#1]
16:46:47,812 DEBUG SessionImpl:3064 - 1 collections initialized
16:46:47,812 DEBUG SessionImpl:3082 - initializing non-lazy collections
16:46:47,812 DEBUG SessionImpl:3227 - collection initialized
16:46:47,812 INFO Main:34 - Parent: 1, []
16:46:47,812 DEBUG SessionImpl:1950 - loading [hex.Child#2]
16:46:47,812 DEBUG SessionImpl:2047 - attempting to resolve [hex.Child#2]
16:46:47,812 DEBUG SessionImpl:2080 - object not resolved in any cache [hex.Child#2]
16:46:47,812 DEBUG EntityPersister:416 - Materializing entity: [hex.Child#2]
16:46:47,812 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
16:46:47,812 DEBUG SQL:237 - select child0_.id as id1_, child0_.value as value1_, child0_.parent as parent1_, parent1_.id as id0_, parent1_.value as value0_ from Child child0_ left outer join Parent parent1_ on child0_.parent=parent1_.value where child0_.id=?
Hibernate: select child0_.id as id1_, child0_.value as value1_, child0_.parent as parent1_, parent1_.id as id0_, parent1_.value as value0_ from Child child0_ left outer join Parent parent1_ on child0_.parent=parent1_.value where child0_.id=?
16:46:47,812 DEBUG BatcherImpl:241 - preparing statement
16:46:47,812 DEBUG IntegerType:46 - binding '2' to parameter: 1
16:46:47,828 DEBUG Loader:197 - processing result set
16:46:47,828 DEBUG IntegerType:68 - returning '1' as column: id0_
16:46:47,828 DEBUG Loader:405 - result row: 1, 2
16:46:47,828 DEBUG Loader:536 - Initializing object from ResultSet: 2
16:46:47,828 DEBUG Loader:605 - Hydrating entity: hex.Child#2
16:46:47,828 DEBUG StringType:68 - returning 'c2 of p1' as column: value1_
16:46:47,828 DEBUG StringType:68 - returning 'p1' as column: parent1_
16:46:47,828 DEBUG Loader:226 - done processing result set (1 rows)
16:46:47,828 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
16:46:47,828 DEBUG BatcherImpl:261 - closing statement
16:46:47,828 DEBUG Loader:239 - total objects hydrated: 1
16:46:47,828 DEBUG SessionImpl:2166 - resolving associations for [hex.Child#2]
16:46:47,828 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
16:46:47,828 DEBUG SQL:237 - select parent0_.id as id0_, parent0_.value as value0_ from Parent parent0_ where parent0_.value=?
Hibernate: select parent0_.id as id0_, parent0_.value as value0_ from Parent parent0_ where parent0_.value=?
16:46:47,828 DEBUG BatcherImpl:241 - preparing statement
16:46:47,828 DEBUG StringType:46 - binding 'p1' to parameter: 1
16:46:47,828 DEBUG Loader:197 - processing result set
16:46:47,828 DEBUG IntegerType:68 - returning '1' as column: id0_
16:46:47,843 DEBUG Loader:405 - result row: 1
16:46:47,843 DEBUG Loader:226 - done processing result set (1 rows)
16:46:47,843 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
16:46:47,843 DEBUG BatcherImpl:261 - closing statement
16:46:47,843 DEBUG Loader:239 - total objects hydrated: 0
16:46:47,843 DEBUG SessionImpl:2190 - done materializing entity [hex.Child#2]
16:46:47,843 DEBUG SessionImpl:3082 - initializing non-lazy collections
16:46:47,843 INFO Main:36 - Child: 2
16:46:47,843 DEBUG JDBCTransaction:59 - commit
16:46:47,843 DEBUG SessionImpl:2210 - flushing session
16:46:47,843 DEBUG SessionImpl:2403 - Flushing entities and processing referenced collections
16:46:47,843 DEBUG SessionImpl:2850 - Collection found: [hex.Parent.childs#1], was: [hex.Parent.childs#1]
16:46:47,843 DEBUG SessionImpl:2746 - Processing unreferenced collections
16:46:47,843 DEBUG SessionImpl:2760 - Scheduling collection removes/(re)creates/updates
16:46:47,843 DEBUG SessionImpl:2234 - Flushed: 0 insertions, 0 updates, 0 deletions to 2 objects
16:46:47,843 DEBUG SessionImpl:2239 - Flushed: 0 (re)creations, 0 updates, 0 removals to 1 collections
16:46:47,843 DEBUG Printer:75 - listing entities:
16:46:47,843 DEBUG Printer:82 - hex.Parent{childs=[], value=p1, id=1}
16:46:47,843 DEBUG Printer:82 - hex.Child{value=c2 of p1, parent=Parent#1, id=2}
16:46:47,843 DEBUG SessionImpl:2323 - executing flush
16:46:47,843 DEBUG SessionImpl:2790 - post flush
16:46:47,859 DEBUG SessionImpl:561 - transaction completion
16:46:47,859 DEBUG SessionImpl:549 - closing session
16:46:47,859 DEBUG SessionImpl:3294 - disconnecting session
16:46:47,859 DEBUG DriverManagerConnectionProvider:114 - returning connection to pool, pool size: 1
16:46:47,859 DEBUG SessionImpl:561 - transaction completion
16:46:47,859 INFO Main:58 - close sf
16:46:47,859 INFO SessionFactoryImpl:531 - closing
16:46:47,859 INFO DriverManagerConnectionProvider:137 - cleaning up connection pool: jdbc:mysql://204.1.213.186:3306/test