-->
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.  [ 9 posts ] 
Author Message
 Post subject: Two associations with nodes (EntityMode.DOM4J)
PostPosted: Wed Oct 26, 2005 7:11 pm 
Newbie

Joined: Fri Mar 04, 2005 2:02 pm
Posts: 18
Hello-

I know the EntityMode.DOM4J stuff is experimental, but I'm curious if I've found a limitation or something that I'm doing wrong. I've used the test/org/hibernate/test/dom4j/AB.xml mapping file (modified below) and the test/org/hibernate/test/dom4j/Dom4JTest.java (unmodified) to demonstrate what I"m trying to do.

I want to have two sets (B,C) referenced from a parent class (A). So I added a new entity (C) to the AB.xml file and the set to it from A. I'm using the node="." on the C set (just like its done on the B set) and I'm getting the error reported below (shared reference) when I run: ant junitsingle -Dtestname="org.hibernate.test.dom4j.Dom4jTest"

Thanks for any help or ideas!

Hibernate version:
3.1.rc2

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping >

<class entity-name="A"
table="A"
node="a">
<id name="aId"
type="int"
column="aId"
node="@id"/>
<property name="x"
type="string"/>
<set name="bs"
node="."
embed-xml="true"
cascade="all"
inverse="true">
<key column="aId"/>
<one-to-many class="B"/>
</set>
<!--------------------------START ADD -------------->
<set name="cs"
node="."
cascade="all">
<key column="cId"/>
<one-to-many class="C"/>
</set>
<!--------------------------END ADD ---------------->
</class>
<!--------------------------START ADD-------------->
<class entity-name="C"
table="C"
node="c">
<id name="cId"
type="int"
column="cId"
node="@id"/>
</class>
<!--------------------------IEND ADD---------------->
<class entity-name="B"
table="B"
node="b">
<composite-id>
<key-property
name="bId"
column="bId"
type="int"
node="@bId"/>
<key-property
name="aId"
column="aId"
type="int"
node="@aId"/>
</composite-id>
<property name="y"
type="string"
node="."/>
</class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
No changes to the current Dom4JTest.java class (the mapping file won't compile)

Full stack trace of any exception that occurs:
Testcase: testCompositeId took 2.418 sec
Caused an ERROR
Found shared references to a collection
org.hibernate.HibernateException: Found shared references to a collection
at org.hibernate.engine.Collections.processReachableCollection(Collections.java:130)
at org.hibernate.event.def.FlushVisitor.processCollection(FlushVisitor.java:37)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:104)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:64)
at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:58)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:198)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:190)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:70)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:329)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at org.hibernate.test.dom4j.Dom4jTest.testCompositeId(Dom4jTest.java:76)
at org.hibernate.test.TestCase.runTest(TestCase.java:129)


Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 10:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
try mapping the node names for those collections to something distinct for each collection, not the same thing.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 9:34 am 
Newbie

Joined: Fri Mar 04, 2005 2:02 pm
Posts: 18
Quote:
try mapping the node names for those collections to something distinct for each collection, not the same thing.


Thanks, that makes sense. I tried changing the mapping file AB.xml to be
<set name="bs"
node="b"
embed-xml="true"
cascade="all"
inverse="true">
<key column="aId"/>
<one-to-many class="B"/>
</set>

<set name="cs"
node="c"
cascade="all">
<key column="cId"/>
<one-to-many class="C"/>
</set>

But then the "b" node never gets picked up and inserted in the unit test...I think it needs the node="." to 'link' them????

Here is the output when run against the change to AB.xml above? No insert to B as in the standard unit test...Ideas?
junitsingle:
[junit] Running org.hibernate.test.dom4j.Dom4jTest
[junit] 06:32:51,708 INFO Environment:464 - Hibernate 3.0.5
[junit] 06:32:51,729 INFO Environment:482 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.hsqldb.jdbcDriver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.max_fetch_depth=1, hibernate.dialect=org.hibernate.dialect.HSQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=sa, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:hsqldb:., hibernate.connection.password=****, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=1}
[junit] 06:32:51,734 INFO Environment:509 - using java.io streams to persist binary types
[junit] 06:32:51,736 INFO Environment:510 - using CGLIB reflection optimizer
[junit] 06:32:51,747 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
[junit] 06:32:51,853 INFO Configuration:427 - Mapping resource: org/hibernate/test/dom4j/AB.hbm.xml
[junit] 06:32:52,364 INFO HbmBinder:260 - Mapping class: A -> A
[junit] 06:32:52,403 INFO HbmBinder:260 - Mapping class: C -> C
[junit] 06:32:52,406 INFO HbmBinder:260 - Mapping class: B -> B
[junit] 06:32:52,444 INFO Dialect:92 - Using dialect: org.hibernate.dialect.HSQLDialect
[junit] 06:32:52,523 INFO Configuration:875 - processing extends queue
[junit] 06:32:52,525 INFO Configuration:879 - processing collection mappings
[junit] 06:32:52,527 INFO HbmBinder:2041 - Mapping collection: A.bs -> B
[junit] 06:32:52,534 INFO HbmBinder:2041 - Mapping collection: A.cs -> C
[junit] 06:32:52,536 INFO Configuration:888 - processing association property references
[junit] 06:32:52,538 INFO Configuration:917 - processing foreign key constraints
[junit] 06:32:52,667 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
[junit] 06:32:52,670 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
[junit] 06:32:52,672 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
[junit] 06:32:52,680 INFO DriverManagerConnectionProvider:80 - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:.
[junit] 06:32:52,682 INFO DriverManagerConnectionProvider:86 - connection properties: {user=sa, password=****}
[junit] 06:32:53,147 INFO SettingsFactory:77 - RDBMS: HSQL Database Engine, version: 1.8.0
[junit] 06:32:53,149 INFO SettingsFactory:78 - JDBC driver: HSQL Database Engine Driver, version: 1.8.0
[junit] 06:32:53,155 INFO Dialect:92 - Using dialect: org.hibernate.dialect.HSQLDialect
[junit] 06:32:53,162 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
[junit] 06:32:53,167 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
[junit] 06:32:53,169 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
[junit] 06:32:53,170 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
[junit] 06:32:53,172 INFO SettingsFactory:136 - JDBC batch size: 15
[junit] 06:32:53,173 INFO SettingsFactory:139 - JDBC batch updates for versioned data: enabled
[junit] 06:32:53,176 INFO SettingsFactory:144 - Scrollable result sets: enabled
[junit] 06:32:53,177 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
[junit] 06:32:53,179 INFO SettingsFactory:160 - Connection release mode: null
[junit] 06:32:53,181 INFO SettingsFactory:184 - Maximum outer join fetch depth: 1
[junit] 06:32:53,183 INFO SettingsFactory:187 - Default batch fetch size: 1
[junit] 06:32:53,184 INFO SettingsFactory:191 - Generate SQL with comments: disabled
[junit] 06:32:53,185 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
[junit] 06:32:53,187 INFO SettingsFactory:334 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[junit] 06:32:53,193 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
[junit] 06:32:53,196 INFO SettingsFactory:203 - Query language substitutions: {no='N', true=1, yes='Y', false=0}
[junit] 06:32:53,197 INFO SettingsFactory:209 - Second-level cache: enabled
[junit] 06:32:53,198 INFO SettingsFactory:213 - Query cache: disabled
[junit] 06:32:53,200 INFO SettingsFactory:321 - Cache provider: org.hibernate.cache.HashtableCacheProvider
[junit] 06:32:53,203 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
[junit] 06:32:53,204 INFO SettingsFactory:233 - Cache region prefix: hibernate.test
[junit] 06:32:53,206 INFO SettingsFactory:237 - Structured second-level cache entries: disabled
[junit] 06:32:53,222 INFO SettingsFactory:261 - Statistics: disabled
[junit] 06:32:53,224 INFO SettingsFactory:265 - Deleted entity synthetic identifier rollback: disabled
[junit] 06:32:53,226 INFO SettingsFactory:279 - Default entity-mode: pojo
[junit] 06:32:53,439 INFO SessionFactoryImpl:152 - building session factory
[junit] 06:32:53,697 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
[junit] 06:32:53,705 INFO Dialect:92 - Using dialect: org.hibernate.dialect.HSQLDialect
[junit] 06:32:53,709 INFO Configuration:875 - processing extends queue
[junit] 06:32:53,710 INFO Configuration:879 - processing collection mappings
[junit] 06:32:53,711 INFO Configuration:888 - processing association property references
[junit] 06:32:53,712 INFO Configuration:917 - processing foreign key constraints
[junit] 06:32:53,715 INFO Configuration:875 - processing extends queue
[junit] 06:32:53,716 INFO Configuration:879 - processing collection mappings
[junit] 06:32:53,717 INFO Configuration:888 - processing association property references
[junit] 06:32:53,718 INFO Configuration:917 - processing foreign key constraints
[junit] 06:32:53,721 INFO SchemaExport:113 - Running hbm2ddl schema export
[junit] 06:32:53,722 INFO SchemaExport:129 - exporting generated schema to database
[junit] 06:32:53,723 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
[junit] 06:32:53,725 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
[junit] 06:32:53,726 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
[junit] 06:32:53,727 INFO DriverManagerConnectionProvider:80 - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:.
[junit] 06:32:53,729 INFO DriverManagerConnectionProvider:86 - connection properties: {user=sa, password=****}
[junit] 06:32:53,730 DEBUG SchemaExport:143 - alter table B drop constraint FK421797D
[junit] 06:32:53,739 DEBUG SchemaExport:149 - Unsuccessful: alter table B drop constraint FK421797D
[junit] 06:32:53,741 DEBUG SchemaExport:150 - Table not found: B in statement [alter table B]
[junit] 06:32:53,742 DEBUG SchemaExport:143 - alter table C drop constraint FK43180FF
[junit] 06:32:53,743 DEBUG SchemaExport:149 - Unsuccessful: alter table C drop constraint FK43180FF
[junit] 06:32:53,744 DEBUG SchemaExport:150 - Table not found: C in statement [alter table C]
[junit] 06:32:53,745 DEBUG SchemaExport:143 - drop table A if exists
[junit] 06:32:53,746 DEBUG SchemaExport:143 - drop table B if exists
[junit] 06:32:53,747 DEBUG SchemaExport:143 - drop table C if exists
[junit] 06:32:53,749 DEBUG SchemaExport:161 - create table A (
[junit] aId integer not null,
[junit] x varchar(255),
[junit] primary key (aId)
[junit] )
[junit] 06:32:53,756 DEBUG SchemaExport:161 - create table B (
[junit] bId integer not null,
[junit] aId integer not null,
[junit] y varchar(255),
[junit] primary key (bId, aId)
[junit] )
[junit] 06:32:53,758 DEBUG SchemaExport:161 - create table C (
[junit] cId integer not null,
[junit] primary key (cId)
[junit] )
[junit] 06:32:53,761 DEBUG SchemaExport:161 - alter table B
[junit] add constraint FK421797D
[junit] foreign key (aId)
[junit] references A
[junit] 06:32:53,772 DEBUG SchemaExport:161 - alter table C
[junit] add constraint FK43180FF
[junit] foreign key (cId)
[junit] references A
[junit] 06:32:53,774 INFO SchemaExport:173 - schema export complete
[junit] 06:32:53,777 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:hsqldb:.
[junit] 06:32:53,779 INFO Dialect:92 - Using dialect: org.hibernate.dialect.HSQLDialect
[junit] 06:32:53,782 INFO Configuration:875 - processing extends queue
[junit] 06:32:53,783 INFO Configuration:879 - processing collection mappings
[junit] 06:32:53,784 INFO Configuration:888 - processing association property references
[junit] 06:32:53,785 INFO Configuration:917 - processing foreign key constraints
[junit] 06:32:53,787 INFO Configuration:875 - processing extends queue
[junit] 06:32:53,788 INFO Configuration:879 - processing collection mappings
[junit] 06:32:53,789 INFO Configuration:888 - processing association property references
[junit] 06:32:53,790 INFO Configuration:917 - processing foreign key constraints
[junit] 06:32:53,794 INFO SessionFactoryImpl:379 - Checking 0 named queries
[junit] 06:32:53,936 DEBUG SQL:324 - insert into A (x, aId) values (?, ?)
[junit] 06:32:53,949 DEBUG StringType:59 - binding 'foo bar' to parameter: 1
[junit] 06:32:53,951 DEBUG IntegerType:59 - binding '1' to parameter: 2
[junit] 06:32:53,998 DEBUG SQL:324 - select this_.aId as aId0_, this_.x as x0_0_ from A this_
[junit] 06:32:54,013 DEBUG IntegerType:86 - returning '1' as column: aId0_
[junit] 06:32:54,018 DEBUG StringType:86 - returning 'foo bar' as column: x0_0_
[junit] 06:32:54,029 DEBUG SQL:324 - select bs0_.aId as aId1_, bs0_.bId as bId1_, bs0_.bId as bId0_, bs0_.aId as aId0_, bs0_.y as y2_0_ from B bs0_ where bs0_.aId=?
[junit] 06:32:54,032 DEBUG IntegerType:59 - binding '1' to parameter: 1
[junit] 06:32:54,038 DEBUG SQL:324 - select cs0_.cId as cId1_, cs0_.cId as cId0_ from C cs0_ where cs0_.cId=?
[junit] 06:32:54,040 DEBUG IntegerType:59 - binding '1' to parameter: 1
[junit] 06:32:54,054 INFO SessionFactoryImpl:776 - closing
[junit] 06:32:54,054 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:hsqldb:.
[junit] 06:32:54,057 INFO SchemaExport:113 - Running hbm2ddl schema export
[junit] 06:32:54,058 INFO SchemaExport:129 - exporting generated schema to database
[junit] 06:32:54,059 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
[junit] 06:32:54,060 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
[junit] 06:32:54,061 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
[junit] 06:32:54,063 INFO DriverManagerConnectionProvider:80 - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:.
[junit] 06:32:54,064 INFO DriverManagerConnectionProvider:86 - connection properties: {user=sa, password=****}
[junit] 06:32:54,067 DEBUG SchemaExport:143 - alter table B drop constraint FK421797D
[junit] 06:32:54,069 DEBUG SchemaExport:143 - alter table C drop constraint FK43180FF
[junit] 06:32:54,070 DEBUG SchemaExport:143 - drop table A if exists
[junit] 06:32:54,072 DEBUG SchemaExport:143 - drop table B if exists
[junit] 06:32:54,073 DEBUG SchemaExport:143 - drop table C if exists
[junit] 06:32:54,074 INFO SchemaExport:173 - schema export complete
[junit] 06:32:54,075 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:hsqldb:.
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 3.107 sec
[junit] Test org.hibernate.test.dom4j.Dom4jTest FAILED

BUILD SUCCESSFUL


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 6:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
what does the code and/or xml document look like that you are trying to use to insert data here?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 6:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Based on that new mapping, I would expect something like:

<a id="1">
<b>
<b aId="1" bId="2">b2-y-value</b>
<b aId="1" bId="3">b3-y-value</b>
</b>
<c>
<c id="4"/>
</c>
</a>

Is that what you are using?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 28, 2005 10:29 am 
Newbie

Joined: Fri Mar 04, 2005 2:02 pm
Posts: 18
Steve,

Thank you very much for your help. I'm using the hibernate unit test test/org/hibernate/test/dom4j/Dom4jTest.java method testCompositeId (I've also posted the code below). If I do a printout of the xml generated I get:
<a id="1">
<x>foo bar</x>
<b bId="1" aId="1">foo foo</b>
<b bId="2" aId="1">bar bar</b>
</a>
which looks a *little* different than yours...I'm not sure how to map this.

i'm not getting the insert into B (as shown in the output in my previous post).

It looks like the node="." is necessary to link the parent and child here? but I can't seem to have two node="." on the same parent? Basically I want to do what the unit test does but add another child C that looks just like B? Any ideas?

Code from hibernate unit test test/org/hibernate/test/dom4j/Dom4jTest.java

public void testCompositeId() throws Exception {
Element a = DocumentFactory.getInstance().createElement( "a" );
a.addAttribute("id", "1");
a.addElement("x").setText("foo bar");
//Element bs = a.addElement("bs");
Element b = a.addElement("b");
//b.addElement("bId").setText("1");
//b.addElement("aId").setText("1");
b.addAttribute("bId", "1");
b.addAttribute("aId", "1");
b.setText("foo foo");
b = a.addElement("b");
//b.addElement("bId").setText("2");
//b.addElement("aId").setText("1");
b.addAttribute("bId", "2");
b.addAttribute("aId", "1");
b.setText("bar bar");

Session s = openSession();
Session dom4jSession = s.getSession( EntityMode.DOM4J );
Transaction t = s.beginTransaction();
dom4jSession.persist("A", a);
t.commit();
s.close();

s = openSession();
dom4jSession = s.getSession( EntityMode.DOM4J );
t = s.beginTransaction();
a = (Element) dom4jSession.createCriteria("A").uniqueResult();
assertEquals( a.elements("b").size(), 2 );
print(a);
dom4jSession.delete(a);
t.commit();
s.close();
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 28, 2005 10:51 am 
Newbie

Joined: Fri Mar 04, 2005 2:02 pm
Posts: 18
To further clarify what I'm looking for here is a new unit test and mapping file for Dom4jTest

public void testTwoChildrenSets() throws Exception {
Element a = DocumentFactory.getInstance().createElement( "a" );
a.addAttribute("id", "1");
Element b = a.addElement("b");
b.addAttribute("bId", "1");
b.addAttribute("aId", "1");
b.setText("foo foo");
b = a.addElement("b");
b.addAttribute("bId", "2");
b.addAttribute("aId", "1");
b.setText("bar bar");

Element c = a.addElement("c");
c.addAttribute("cId", "1");
c.addAttribute("aId","1");

print(a);

Session s = openSession();
Session dom4jSession = s.getSession( EntityMode.DOM4J );
Transaction t = s.beginTransaction();
dom4jSession.persist("A", a);
t.commit();
s.close();

s = openSession();
dom4jSession = s.getSession( EntityMode.DOM4J );
t = s.beginTransaction();
a = (Element) dom4jSession.createCriteria("A").uniqueResult();
assertEquals( a.elements("b").size(), 2 );
assertEquals( a.elements("c").size(),1);

print(a);

dom4jSession.delete( a);
t.commit();
s.close();

}



mapping file AB.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping >

<class entity-name="A"
table="A"
node="a">
<id name="aId"
type="int"
column="aId"
node="@id"/>
<property name="x"
type="string"/>
<set name="bs"
node="b"
embed-xml="true"
cascade="all"
inverse="true">
<key column="aId"/>
<one-to-many class="B"/>
</set>

<set name="cs"
node="c"
cascade="all">
<key column="cId"/>
<one-to-many class="C"/>
</set>

</class>

<class entity-name="C"
table="C"
node="c">
<id name="cId"
type="int"
column="cId"
node="@id"/>
</class>

<class entity-name="B"
table="B"
node="b">
<composite-id>
<key-property
name="bId"
column="bId"
type="int"
node="@bId"/>
<key-property
name="aId"
column="aId"
type="int"
node="@aId"/>
</composite-id>
<property name="y"
type="string"
node="."/>
</class>

</hibernate-mapping>

output of run
ant junitsingle -Dtestname="org.hibernate.test.dom4j.Dom4jTest"
Buildfile: build.xml
Trying to override old definition of datatype junit
Trying to override old definition of datatype junitreport
[taskdef] Could not load definitions from resource checkstyletask.properties. It could not be found.
[taskdef] Could not load definitions from resource clovertasks. It could not be found.

cleantestdb:

compiletest:

junitsingle:
[junit] Running org.hibernate.test.dom4j.Dom4jTest
[junit] 07:54:32,782 INFO Environment:464 - Hibernate 3.0.5
[junit] 07:54:32,796 INFO Environment:482 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.hsqldb.jdbcDriver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.max_fetch_depth=1, hibernate.dialect=org.hibernate.dialect.HSQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=sa, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:hsqldb:., hibernate.connection.password=****, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=1}
[junit] 07:54:32,800 INFO Environment:509 - using java.io streams to persist binary types
[junit] 07:54:32,803 INFO Environment:510 - using CGLIB reflection optimizer
[junit] 07:54:32,813 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
[junit] 07:54:32,920 INFO Configuration:427 - Mapping resource: org/hibernate/test/dom4j/AB.hbm.xml
[junit] 07:54:33,421 INFO HbmBinder:260 - Mapping class: A -> A
[junit] 07:54:33,459 INFO HbmBinder:260 - Mapping class: C -> C
[junit] 07:54:33,462 INFO HbmBinder:260 - Mapping class: B -> B
[junit] 07:54:33,500 INFO Dialect:92 - Using dialect: org.hibernate.dialect.HSQLDialect
[junit] 07:54:33,579 INFO Configuration:875 - processing extends queue
[junit] 07:54:33,580 INFO Configuration:879 - processing collection mappings
[junit] 07:54:33,582 INFO HbmBinder:2041 - Mapping collection: A.bs -> B
[junit] 07:54:33,589 INFO HbmBinder:2041 - Mapping collection: A.cs -> C
[junit] 07:54:33,592 INFO Configuration:888 - processing association property references
[junit] 07:54:33,593 INFO Configuration:917 - processing foreign key constraints
[junit] 07:54:33,710 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
[junit] 07:54:33,712 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
[junit] 07:54:33,714 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
[junit] 07:54:33,722 INFO DriverManagerConnectionProvider:80 - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:.
[junit] 07:54:33,725 INFO DriverManagerConnectionProvider:86 - connection properties: {user=sa, password=****}
[junit] 07:54:34,175 INFO SettingsFactory:77 - RDBMS: HSQL Database Engine, version: 1.8.0
[junit] 07:54:34,177 INFO SettingsFactory:78 - JDBC driver: HSQL Database Engine Driver, version: 1.8.0
[junit] 07:54:34,182 INFO Dialect:92 - Using dialect: org.hibernate.dialect.HSQLDialect
[junit] 07:54:34,189 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
[junit] 07:54:34,194 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
[junit] 07:54:34,195 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
[junit] 07:54:34,197 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
[junit] 07:54:34,198 INFO SettingsFactory:136 - JDBC batch size: 15
[junit] 07:54:34,199 INFO SettingsFactory:139 - JDBC batch updates for versioned data: enabled
[junit] 07:54:34,202 INFO SettingsFactory:144 - Scrollable result sets: enabled
[junit] 07:54:34,203 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
[junit] 07:54:34,204 INFO SettingsFactory:160 - Connection release mode: null
[junit] 07:54:34,207 INFO SettingsFactory:184 - Maximum outer join fetch depth: 1
[junit] 07:54:34,208 INFO SettingsFactory:187 - Default batch fetch size: 1
[junit] 07:54:34,210 INFO SettingsFactory:191 - Generate SQL with comments: disabled
[junit] 07:54:34,211 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
[junit] 07:54:34,212 INFO SettingsFactory:334 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[junit] 07:54:34,218 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
[junit] 07:54:34,220 INFO SettingsFactory:203 - Query language substitutions: {no='N', true=1, yes='Y', false=0}
[junit] 07:54:34,221 INFO SettingsFactory:209 - Second-level cache: enabled
[junit] 07:54:34,222 INFO SettingsFactory:213 - Query cache: disabled
[junit] 07:54:34,224 INFO SettingsFactory:321 - Cache provider: org.hibernate.cache.HashtableCacheProvider
[junit] 07:54:34,227 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
[junit] 07:54:34,229 INFO SettingsFactory:233 - Cache region prefix: hibernate.test
[junit] 07:54:34,230 INFO SettingsFactory:237 - Structured second-level cache entries: disabled
[junit] 07:54:34,246 INFO SettingsFactory:261 - Statistics: disabled
[junit] 07:54:34,249 INFO SettingsFactory:265 - Deleted entity synthetic identifier rollback: disabled
[junit] 07:54:34,251 INFO SettingsFactory:279 - Default entity-mode: pojo
[junit] 07:54:34,452 INFO SessionFactoryImpl:152 - building session factory
[junit] 07:54:34,698 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
[junit] 07:54:34,705 INFO Dialect:92 - Using dialect: org.hibernate.dialect.HSQLDialect
[junit] 07:54:34,709 INFO Configuration:875 - processing extends queue
[junit] 07:54:34,710 INFO Configuration:879 - processing collection mappings
[junit] 07:54:34,711 INFO Configuration:888 - processing association property references
[junit] 07:54:34,712 INFO Configuration:917 - processing foreign key constraints
[junit] 07:54:34,714 INFO Configuration:875 - processing extends queue
[junit] 07:54:34,715 INFO Configuration:879 - processing collection mappings
[junit] 07:54:34,716 INFO Configuration:888 - processing association property references
[junit] 07:54:34,716 INFO Configuration:917 - processing foreign key constraints
[junit] 07:54:34,719 INFO SchemaExport:113 - Running hbm2ddl schema export
[junit] 07:54:34,720 INFO SchemaExport:129 - exporting generated schema to database
[junit] 07:54:34,721 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
[junit] 07:54:34,722 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
[junit] 07:54:34,723 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
[junit] 07:54:34,724 INFO DriverManagerConnectionProvider:80 - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:.
[junit] 07:54:34,725 INFO DriverManagerConnectionProvider:86 - connection properties: {user=sa, password=****}
[junit] 07:54:34,727 DEBUG SchemaExport:143 - alter table B drop constraint FK421797D
[junit] 07:54:34,736 DEBUG SchemaExport:149 - Unsuccessful: alter table B drop constraint FK421797D
[junit] 07:54:34,737 DEBUG SchemaExport:150 - Table not found: B in statement [alter table B]
[junit] 07:54:34,737 DEBUG SchemaExport:143 - alter table C drop constraint FK43180FF
[junit] 07:54:34,739 DEBUG SchemaExport:149 - Unsuccessful: alter table C drop constraint FK43180FF
[junit] 07:54:34,739 DEBUG SchemaExport:150 - Table not found: C in statement [alter table C]
[junit] 07:54:34,740 DEBUG SchemaExport:143 - drop table A if exists
[junit] 07:54:34,741 DEBUG SchemaExport:143 - drop table B if exists
[junit] 07:54:34,742 DEBUG SchemaExport:143 - drop table C if exists
[junit] 07:54:34,744 DEBUG SchemaExport:161 - create table A (
[junit] aId integer not null,
[junit] x varchar(255),
[junit] primary key (aId)
[junit] )
[junit] 07:54:34,750 DEBUG SchemaExport:161 - create table B (
[junit] bId integer not null,
[junit] aId integer not null,
[junit] y varchar(255),
[junit] primary key (bId, aId)
[junit] )
[junit] 07:54:34,752 DEBUG SchemaExport:161 - create table C (
[junit] cId integer not null,
[junit] primary key (cId)
[junit] )
[junit] 07:54:34,754 DEBUG SchemaExport:161 - alter table B
[junit] add constraint FK421797D
[junit] foreign key (aId)
[junit] references A
[junit] 07:54:34,766 DEBUG SchemaExport:161 - alter table C
[junit] add constraint FK43180FF
[junit] foreign key (cId)
[junit] references A
[junit] 07:54:34,767 INFO SchemaExport:173 - schema export complete
[junit] 07:54:34,770 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:hsqldb:.
[junit] 07:54:34,771 INFO Dialect:92 - Using dialect: org.hibernate.dialect.HSQLDialect
[junit] 07:54:34,774 INFO Configuration:875 - processing extends queue
[junit] 07:54:34,775 INFO Configuration:879 - processing collection mappings
[junit] 07:54:34,776 INFO Configuration:888 - processing association property references
[junit] 07:54:34,777 INFO Configuration:917 - processing foreign key constraints
[junit] 07:54:34,778 INFO Configuration:875 - processing extends queue
[junit] 07:54:34,779 INFO Configuration:879 - processing collection mappings
[junit] 07:54:34,780 INFO Configuration:888 - processing association property references
[junit] 07:54:34,781 INFO Configuration:917 - processing foreign key constraints
[junit] 07:54:34,784 INFO SessionFactoryImpl:379 - Checking 0 named queries

[junit] <a id="1">
[junit] <b bId="1" aId="1">foo foo</b>
[junit] <b bId="2" aId="1">bar bar</b>
[junit] <c cId="1" aId="1"/>
[junit] </a>07:54:34,936 DEBUG SQL:324 - insert into A (x, aId) values (?, ?)
[junit] 07:54:34,949 DEBUG StringType:52 - binding null to parameter: 1
[junit] 07:54:34,950 DEBUG IntegerType:59 - binding '1' to parameter: 2
[junit] 07:54:34,994 DEBUG SQL:324 - select this_.aId as aId0_, this_.x as x0_0_ from A this_
[junit] 07:54:35,009 DEBUG IntegerType:86 - returning '1' as column: aId0_
[junit] 07:54:35,014 DEBUG StringType:80 - returning null as column: x0_0_
[junit] 07:54:35,024 DEBUG SQL:324 - select bs0_.aId as aId1_, bs0_.bId as bId1_, bs0_.bId as bId0_, bs0_.aId as aId0_, bs0_.y as y2_0_ from B bs0_ where bs0_.aId=?
[junit] 07:54:35,027 DEBUG IntegerType:59 - binding '1' to parameter: 1
[junit] 07:54:35,031 DEBUG SQL:324 - select cs0_.cId as cId1_, cs0_.cId as cId0_ from C cs0_ where cs0_.cId=?
[junit] 07:54:35,034 DEBUG IntegerType:59 - binding '1' to parameter: 1
[junit] 07:54:35,046 INFO SessionFactoryImpl:776 - closing
[junit] 07:54:35,047 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:hsqldb:.
[junit] 07:54:35,050 INFO SchemaExport:113 - Running hbm2ddl schema export
[junit] 07:54:35,050 INFO SchemaExport:129 - exporting generated schema to database
[junit] 07:54:35,051 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
[junit] 07:54:35,052 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
[junit] 07:54:35,053 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
[junit] 07:54:35,054 INFO DriverManagerConnectionProvider:80 - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:.
[junit] 07:54:35,055 INFO DriverManagerConnectionProvider:86 - connection properties: {user=sa, password=****}
[junit] 07:54:35,057 DEBUG SchemaExport:143 - alter table B drop constraint FK421797D
[junit] 07:54:35,058 DEBUG SchemaExport:143 - alter table C drop constraint FK43180FF
[junit] 07:54:35,059 DEBUG SchemaExport:143 - drop table A if exists
[junit] 07:54:35,061 DEBUG SchemaExport:143 - drop table B if exists
[junit] 07:54:35,062 DEBUG SchemaExport:143 - drop table C if exists
[junit] 07:54:35,064 INFO SchemaExport:173 - schema export complete
[junit] 07:54:35,065 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:hsqldb:.
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 3.012 sec
[junit] Test org.hibernate.test.dom4j.Dom4jTest FAILED

BUILD SUCCESSFUL
Total time: 7 seconds


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 20, 2006 1:00 pm 
Newbie

Joined: Wed Dec 13, 2006 5:49 am
Posts: 3
Location: Copenhagen
dohunt wrote:
It looks like the node="." is necessary to link the parent and child here? but I can't seem to have two node="." on the same parent? Basically I want to do what the unit test does but add another child C that looks just like B? Any ideas?


dohunt,

Dit you ever get this to work?

I'm having the same problem, which for me is basically a problem of doing
XML to Relational Mapping, using surrogate keys.

/
Peter


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 25, 2007 8:39 am 
Newbie

Joined: Sun Mar 25, 2007 8:33 am
Posts: 2
I'm facing the same problem currently, did you find any workaround/solutions for this problem?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.