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