-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: cascade for @CollectionOfElements?
PostPosted: Tue Jan 24, 2006 3:02 pm 
Newbie

Joined: Sat Jan 07, 2006 10:33 am
Posts: 18
Location: New York NY
The docs say that @CollectionOfElements replaces @OneToMany. @OneToMany has a "cascade" attribute, but @CollectionOfElements does not. Does this mean that save and other operations have to be "manually" performed on the items in a collection mapped by @CollectionOfElements? I get a TransientObjectException when I try the simple test below. Note the "Cascading children with null" message in the log.

If, however, I add a "session.save(child);" line before "session.save(parent)" below, then everything seems to be written to the database correctly.

What do I need to do to get cascading of saves to work for @CollectionOfElements?

Hibernate version: 3.1.1, Annotation 3.1beta8

Mapping documents:
Code:
@Entity
public class Parent
{
    @Id
    @GeneratedValue
    private Long id;

    @CollectionOfElements
    @MapKey
    private Map<String, Child> children = new HashMap<String, Child>();
   
    public Parent() {}
   
    public void addChild(Child child)
    {
        this.children.put("" + System.currentTimeMillis(), child);
    }
}

Code:
@Entity
public class Child
{
    @Id
    @GeneratedValue
    private Long id;
   
    public Child() {}
}


Code between sessionFactory.openSession() and session.close():
(before opening session)
Code:
        Parent parent = new Parent();
        Child child = new Child();
        parent.addChild(child);

(then)
Code:
        Transaction tx = session.beginTransaction();
        session.save(parent);
        tx.commit();


Full stack trace of any exception that occurs:
Code:
Could not synchronize database state with session
org.hibernate.TransientObjectException: org.aitools.Child
   at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
   at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
   at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:71)
   at org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:697)
   at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1037)
   at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:26)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1007)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:354)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
   at org.aitools.TestServlet.doGet(TestServlet.java:32)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Thread.java:595)
Servlet.service() for servlet TestServlet threw exception
org.hibernate.TransientObjectException: org.aitools.Child
   at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
   at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
   at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:71)
   at org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:697)
   at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1037)
   at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:26)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1007)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:354)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
   at org.aitools.TestServlet.doGet(TestServlet.java:32)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Thread.java:595)


Name and version of the database you are using: MySQL 4.1.16

The generated SQL (show_sql=true):
Code:
Static SQL for entity: org.aitools.Parent
Version select: select id from Parent where id =?
Snapshot select: select parent_.id from Parent parent_ where parent_.id=?
Insert 0: insert into Parent (id) values (?)
Update 0: null
Delete 0: delete from Parent where id=?
Identity insert: insert into Parent values ( )
Static SQL for entity: org.aitools.Child
Version select: select id from Child where id =?
Snapshot select: select child_.id from Child child_ where child_.id=?
Insert 0: insert into Child (id) values (?)
Update 0: null
Delete 0: delete from Child where id=?
Identity insert: insert into Child values ( )
Static SQL for collection: org.aitools.Parent.children
Row insert: insert into Parent_Child (Parent_id, children_id) values (?, ?)
Row update: update Parent_Child set children_id=? where Parent_id=? and children_id=?
Row delete: delete from Parent_Child where Parent_id=? and children_id=?
One-shot delete: delete from Parent_Child where Parent_id=?
Static select for entity org.aitools.Parent: select parent0_.id as id0_0_ from Parent parent0_ where parent0_.id=?
Static select for entity org.aitools.Parent: select parent0_.id as id0_0_ from Parent parent0_ where parent0_.id=?
Static select for entity org.aitools.Parent: select parent0_.id as id0_0_ from Parent parent0_ where parent0_.id=? for update
Static select for entity org.aitools.Parent: select parent0_.id as id0_0_ from Parent parent0_ where parent0_.id=? for update
Static select for action ACTION_MERGE on entity org.aitools.Parent: select parent0_.id as id0_0_ from Parent parent0_ where parent0_.id=?
Static select for action ACTION_REFRESH on entity org.aitools.Parent: select parent0_.id as id0_0_ from Parent parent0_ where parent0_.id=?
Static select for entity org.aitools.Child: select child0_.id as id1_0_ from Child child0_ where child0_.id=?
Static select for entity org.aitools.Child: select child0_.id as id1_0_ from Child child0_ where child0_.id=?
Static select for entity org.aitools.Child: select child0_.id as id1_0_ from Child child0_ where child0_.id=? for update
Static select for entity org.aitools.Child: select child0_.id as id1_0_ from Child child0_ where child0_.id=? for update
Static select for action ACTION_MERGE on entity org.aitools.Child: select child0_.id as id1_0_ from Child child0_ where child0_.id=?
Static select for action ACTION_REFRESH on entity org.aitools.Child: select child0_.id as id1_0_ from Child child0_ where child0_.id=?
Static select for collection org.aitools.Parent.children: select children0_.Parent_id as Parent1_1_, children0_.children_id as children2_1_, children0_.id as formula0_1_, child1_.id as id1_0_ from Par
ent_Child children0_ left outer join Child child1_ on children0_.children_id=child1_.id where children0_.Parent_id=?


Debug level Hibernate log excerpt:
Code:
Hibernate 3.1.1
hibernate.properties not found
using CGLIB reflection optimizer
using JDK 1.4 java.sql.Timestamp handling
configuring from resource: /hibernate.cfg.xml
Configuration resource: /hibernate.cfg.xml
trying to locate http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath under org/hibernate/
found http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.password=WERUIOWERUOIWER
hibernate.connection.url=jdbc:mysql:///hibernatetest
hibernate.connection.username=test
connection.pool_size=1
hibernate.dialect=org.hibernate.dialect.MySQLDialect
current_session_context_class=thread
cache.provider_class=org.hibernate.cache.NoCacheProvider
show_sql=true
hbm2ddl.auto=create
hibernate.current_session_context_class=thread
null<-org.dom4j.tree.DefaultAttribute@6cb8 [Attribute: name class value "org.aitools.Parent"]
null<-org.dom4j.tree.DefaultAttribute@ee22f7 [Attribute: name class value "org.aitools.Child"]
Configured SessionFactory: null
properties: {show_sql=true, java.vendor=Sun Microsystems Inc., catalina.base=/home/noel/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1, hibernate.connection.url=jdbc:mysql:///hibernatet
est, sun.management.compiler=HotSpot Client Compiler, catalina.useNaming=true, hbm2ddl.auto=create, os.name=Linux, sun.boot.class.path=/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/rt.jar:/usr/lib/jvm/
java-1.5.0-sun-1.5.0.05/jre/lib/i18n.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/jsse.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/
jce.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/charsets.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/classes, hibernate.current_session_context_class=thread, sun.desktop=gnome, java.vm.specifica
tion.vendor=Sun Microsystems Inc., java.runtime.version=1.5.0_05-b05, hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider, user.name=noel, shared.loader=${catalina.base}/shared/classes,
${catalina.base}/shared/lib/*.jar, tomcat.util.buf.StringCache.byte.enabled=true, current_session_context_class=thread, user.language=en, java.naming.factory.initial=org.apache.naming.java.javaURLCont
extFactory, sun.boot.library.path=/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/i386, java.version=1.5.0_05, user.timezone=America/New_York, sun.arch.data.model=32, java.endorsed.dirs=/usr/local/tomcat
5/common/endorsed, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, file.encoding.pkg=sun.io, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans., fil
e.separator=/, java.specification.name=Java Platform API Specification, hibernate.cglib.use_reflection_optimizer=true, java.class.version=49.0, user.country=US, java.home=/usr/lib/jvm/java-1.5.0-sun-1
.5.0.05/jre, java.vm.info=mixed mode, sharing, os.version=2.6.14-1.1656_FC4, path.separator=:, java.vm.version=1.5.0_05-b05, hibernate.connection.password=WERUIOWERUOIWER, java.awt.printerjob=sun.prin
t.PSPrinterJob, sun.io.unicode.encoding=UnicodeLittle, hibernate.connection.username=test, package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,
java.naming.factory.url.pkgs=org.apache.naming, user.home=/home/noel, java.specification.vendor=Sun Microsystems Inc., hibernate.hbm2ddl.auto=create, java.library.path=/usr/lib/jvm/java-1.5.0-sun-1.5.
0.05/jre/lib/i386/client:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/i386:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/../lib/i386:/usr/lib/mozilla-1.7.12, java.vendor.url=http://java.sun.com/, hibernate
.connection.driver_class=com.mysql.jdbc.Driver, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=org.hibernate.dialect.MySQLDialect, common.loader=${catalina.home}/common/classes,${catalina.hom
e}/common/i18n/*.jar,${catalina.home}/common/endorsed/*.jar,${catalina.home}/common/lib/*.jar, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, java.class.path=/usr/local/tomcat5/bi
n/bootstrap.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/lib/tools.jar, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, catalina.home=/usr/local/tomcat5,
sun.cpu.endian=little, sun.os.patch.level=unknown, connection.pool_size=1, java.io.tmpdir=/tmp, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, server.loader=${catalina.home}/server/cla
sses,${catalina.home}/server/lib/*.jar, os.arch=i386, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.ext.dirs=/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/ext, user.dir=/home/noel, line.sep
arator=
, java.vm.name=Java HotSpot(TM) Client VM, cache.provider_class=org.hibernate.cache.NoCacheProvider, file.encoding=UTF-8, java.specification.version=1.5, hibernate.show_sql=true, hibernate.connection.
pool_size=1}
Preparing to build session factory with filters : {}
Execute first pass mapping processing
Process hbm files
Process annotated classes
Binding entity from annotated class: org.aitools.Parent
Binding column TYPE unique false
Import with entity name=Parent
Bind entity org.aitools.Parent on table Parent
Processing org.aitools.Parent per property annotation
Processing org.aitools.Parent per field annotation
Processing annotations of org.aitools.Parent.id
Binding column id unique false
id is an id
building SimpleValue for id
Building property id
Cascading id with null
Bind @Id on id
Processing annotations of org.aitools.Parent.children
Binding column null unique false
Binding column children unique false
Binding column null unique false
Binding column null unique false
Binding column null unique false
Collection role: org.aitools.Parent.children
Building property children
Cascading children with null
ResourceBundle ValidatorMessages not found. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages
Binding entity from annotated class: org.aitools.Child
Binding column TYPE unique false
Import with entity name=Child
Bind entity org.aitools.Child on table Child
Processing org.aitools.Child per property annotation
Processing org.aitools.Child per field annotation
Processing annotations of org.aitools.Child.id
Binding column id unique false
id is an id
building SimpleValue for id
Building property id
Cascading id with null
Bind @Id on id
ResourceBundle ValidatorMessages not found. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages
processing manytoone fk mappings
processing extends queue
processing collection mappings
Second pass for collection: org.aitools.Parent.children
Binding a OneToMany: org.aitools.Parent.children through an association table
Mapped collection key: Parent_id, index: id, element: children_id
processing native query and ResultSetMapping mappings
processing association property references
processing foreign key constraints
resolving reference to class: org.aitools.Child
resolving reference to class: org.aitools.Parent
Using Hibernate built-in connection pool (not for production use!)
Hibernate connection pool size: 1
autocommit mode: false
using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///hibernatetest
connection properties: {user=test, password=WERUIOWERUOIWER}
total checked-out connections: 0
opening new JDBC connection
created connection to: jdbc:mysql:///hibernatetest, Isolation Level: 4
RDBMS: MySQL, version: 4.1.16-log
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$ )
returning connection to pool, pool size: 1
Using dialect: org.hibernate.dialect.MySQLDialect
Using default transaction strategy (direct JDBC transactions)
No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Automatic flush during beforeCompletion(): disabled
Automatic session close at end of transaction: disabled
JDBC batch size: 15
JDBC batch updates for versioned data: disabled
Scrollable result sets: enabled
Wrap result sets: disabled
JDBC3 getGeneratedKeys(): enabled
Connection release mode: auto
Maximum outer join fetch depth: 2
Default batch fetch size: 1
Generate SQL with comments: disabled
Order SQL updates by primary key: disabled
Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Using ASTQueryTranslatorFactory
Query language substitutions: {}
Second-level cache: enabled
Query cache: disabled
Cache provider: org.hibernate.cache.NoCacheProvider
Optimize cache for minimal puts: disabled
Structured second-level cache entries: disabled
Using dialect defined converter
Echoing all SQL to stdout
Statistics: disabled
Deleted entity synthetic identifier rollback: disabled
Default entity-mode: pojo
building session factory
Session factory constructed with filter configurations : {}
instantiating session factory with properties: {java.vendor=Sun Microsystems Inc., show_sql=true, catalina.base=/home/noel/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1, hibernate.conn
ection.url=jdbc:mysql:///hibernatetest, sun.management.compiler=HotSpot Client Compiler, catalina.useNaming=true, os.name=Linux, hbm2ddl.auto=create, sun.boot.class.path=/usr/lib/jvm/java-1.5.0-sun-1.
5.0.05/jre/lib/rt.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/i18n.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/jsse.jar:/usr/lib/j
vm/java-1.5.0-sun-1.5.0.05/jre/lib/jce.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/charsets.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/classes, hibernate.current_session_context_class=thread, s
un.desktop=gnome, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.5.0_05-b05, hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider, user.name=noel, shared.load
er=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar, tomcat.util.buf.StringCache.byte.enabled=true, current_session_context_class=thread, user.language=en, java.naming.factory.initial
=org.apache.naming.java.javaURLContextFactory, sun.boot.library.path=/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/i386, java.version=1.5.0_05, user.timezone=America/New_York, sun.arch.data.model=32, j
ava.endorsed.dirs=/usr/local/tomcat5/common/endorsed, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, file.encoding.pkg=sun.io, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.
,org.apache.jasper.,sun.beans., file.separator=/, java.specification.name=Java Platform API Specification, hibernate.cglib.use_reflection_optimizer=true, java.class.version=49.0, user.country=US, java
.home=/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre, java.vm.info=mixed mode, sharing, os.version=2.6.14-1.1656_FC4, path.separator=:, java.vm.version=1.5.0_05-b05, hibernate.connection.password=WERUIOWERU
OIWER, java.awt.printerjob=sun.print.PSPrinterJob, sun.io.unicode.encoding=UnicodeLittle, hibernate.connection.username=test, package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.
apache.tomcat.,org.apache.jasper., java.naming.factory.url.pkgs=org.apache.naming, user.home=/home/noel, java.specification.vendor=Sun Microsystems Inc., hibernate.hbm2ddl.auto=create, java.library.pa
th=/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/i386/client:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/i386:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/../lib/i386:/usr/lib/mozilla-1.7.12, java.vendor.
url=http://java.sun.com/, hibernate.connection.driver_class=com.mysql.jdbc.Driver, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=org.hibernate.dialect.MySQLDialect, common.loader=${catalina.
home}/common/classes,${catalina.home}/common/i18n/*.jar,${catalina.home}/common/endorsed/*.jar,${catalina.home}/common/lib/*.jar, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, ja
va.class.path=/usr/local/tomcat5/bin/bootstrap.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/lib/tools.jar, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0,
catalina.home=/usr/local/tomcat5, sun.cpu.endian=little, sun.os.patch.level=unknown, connection.pool_size=1, java.io.tmpdir=/tmp, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, server
.loader=${catalina.home}/server/classes,${catalina.home}/server/lib/*.jar, os.arch=i386, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.ext.dirs=/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib
/ext, user.dir=/home/noel, line.separator=
, java.vm.name=Java HotSpot(TM) Client VM, cache.provider_class=org.hibernate.cache.NoCacheProvider, file.encoding=UTF-8, java.specification.version=1.5, hibernate.connection.pool_size=1, hibernate.sh
ow_sql=true}
Static SQL for entity: org.aitools.Parent
Version select: select id from Parent where id =?
Snapshot select: select parent_.id from Parent parent_ where parent_.id=?
Insert 0: insert into Parent (id) values (?)
Update 0: null
Delete 0: delete from Parent where id=?
Identity insert: insert into Parent values ( )
Static SQL for entity: org.aitools.Child
Version select: select id from Child where id =?
Snapshot select: select child_.id from Child child_ where child_.id=?
Insert 0: insert into Child (id) values (?)
Update 0: null
Delete 0: delete from Child where id=?
Identity insert: insert into Child values ( )
Static SQL for collection: org.aitools.Parent.children
Row insert: insert into Parent_Child (Parent_id, children_id) values (?, ?)
Row update: update Parent_Child set children_id=? where Parent_id=? and children_id=?
Row delete: delete from Parent_Child where Parent_id=? and children_id=?
One-shot delete: delete from Parent_Child where Parent_id=?
Static select for entity org.aitools.Parent: select parent0_.id as id0_0_ from Parent parent0_ where parent0_.id=?
Static select for entity org.aitools.Parent: select parent0_.id as id0_0_ from Parent parent0_ where parent0_.id=?
Static select for entity org.aitools.Parent: select parent0_.id as id0_0_ from Parent parent0_ where parent0_.id=? for update
Static select for entity org.aitools.Parent: select parent0_.id as id0_0_ from Parent parent0_ where parent0_.id=? for update
Static select for action ACTION_MERGE on entity org.aitools.Parent: select parent0_.id as id0_0_ from Parent parent0_ where parent0_.id=?
Static select for action ACTION_REFRESH on entity org.aitools.Parent: select parent0_.id as id0_0_ from Parent parent0_ where parent0_.id=?
Static select for entity org.aitools.Child: select child0_.id as id1_0_ from Child child0_ where child0_.id=?
Static select for entity org.aitools.Child: select child0_.id as id1_0_ from Child child0_ where child0_.id=?
Static select for entity org.aitools.Child: select child0_.id as id1_0_ from Child child0_ where child0_.id=? for update
Static select for entity org.aitools.Child: select child0_.id as id1_0_ from Child child0_ where child0_.id=? for update
Static select for action ACTION_MERGE on entity org.aitools.Child: select child0_.id as id1_0_ from Child child0_ where child0_.id=?
Static select for action ACTION_REFRESH on entity org.aitools.Child: select child0_.id as id1_0_ from Child child0_ where child0_.id=?
Static select for collection org.aitools.Parent.children: select children0_.Parent_id as Parent1_1_, children0_.children_id as children2_1_, children0_.id as formula0_1_, child1_.id as id1_0_ from Par
ent_Child children0_ left outer join Child child1_ on children0_.children_id=child1_.id where children0_.Parent_id=?
initializing class SessionFactoryObjectFactory
registered: ff80808108fdb5560108fdb55a980000 (unnamed)
Not binding factory to JNDI, no JNDI name configured
instantiated session factory
Execute first pass mapping processing
Process hbm files
Process annotated classes
processing manytoone fk mappings
processing extends queue
processing collection mappings
processing native query and ResultSetMapping mappings
processing association property references
processing foreign key constraints
resolving reference to class: org.aitools.Child
resolving reference to class: org.aitools.Parent
Execute first pass mapping processing
Process hbm files
Process annotated classes
processing manytoone fk mappings
processing extends queue
processing collection mappings
processing native query and ResultSetMapping mappings
processing association property references
processing foreign key constraints
resolving reference to class: org.aitools.Child
resolving reference to class: org.aitools.Parent
Running hbm2ddl schema export
import file not found: /import.sql
exporting generated schema to database
total checked-out connections: 0
using pooled JDBC connection, pool size: 0
alter table Parent_Child drop foreign key FK5AF11D472EC2DFD2
alter table Parent_Child drop foreign key FK5AF11D473026197F
drop table if exists Child
drop table if exists Parent
drop table if exists Parent_Child
create table Child (id bigint not null auto_increment, primary key (id))
create table Parent (id bigint not null auto_increment, primary key (id))
create table Parent_Child (Parent_id bigint not null, children_id bigint not null, primary key (Parent_id, children_id), unique (children_id))
alter table Parent_Child add index FK5AF11D472EC2DFD2 (children_id), add constraint FK5AF11D472EC2DFD2 foreign key (children_id) references Child (id)
alter table Parent_Child add index FK5AF11D473026197F (Parent_id), add constraint FK5AF11D473026197F foreign key (Parent_id) references Parent (id)
schema export complete
returning connection to pool, pool size: 1
Checking 0 named HQL queries
Checking 0 named SQL queries
Jan 24, 2006 1:38:07 PM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jan 24, 2006 1:38:07 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jan 24, 2006 1:38:07 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/70  config=null
Jan 24, 2006 1:38:08 PM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Jan 24, 2006 1:38:08 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 5392 ms
opened session at timestamp: 11381278918
allowing method [beginTransaction] in non-transacted context
begin
opening JDBC connection
total checked-out connections: 0
using pooled JDBC connection, pool size: 0
current autocommit status: false
after transaction begin
saving transient instance
saving [org.aitools.Parent#<null>]
executing insertions
Wrapped collection in role: org.aitools.Parent.children
Inserting entity: org.aitools.Parent (native id)
about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
insert into Parent values ( )
Hibernate: insert into Parent values ( )
preparing statement
Dehydrating entity: [org.aitools.Parent#<null>]
Natively generated identity: 1
about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
closing statement
commit
automatically flushing session
flushing session
processing flush-time cascades
dirty checking collections
Flushing entities and processing referenced collections
Collection found: [org.aitools.Parent.children#1], was: [<unreferenced>] (initialized)
Processing unreferenced collections
Scheduling collection removes/(re)creates/updates
Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
Flushed: 1 (re)creations, 0 updates, 0 removals to 1 collections
listing entities:
org.aitools.Parent{children=[org.aitools.Child#null], id=1}
executing flush
Inserting collection: [org.aitools.Parent.children#1]
about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
insert into Parent_Child (Parent_id, children_id) values (?, ?)
Hibernate: insert into Parent_Child (Parent_id, children_id) values (?, ?)
preparing statement
binding '1' to parameter: 1
Could not synchronize database state with session


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 25, 2006 2:50 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Child is not an element (not an embeddable object), but an entity, don't use @Collection OfElements in this case

_________________
Emmanuel


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

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.