I am newbie to hibernate . I download adminapp from
http://www.hibernate.org/Documentation/ ... umentation , and add SchemaExportTask to build.xml to get ddl with successful result.
But when i change the <parent name="user"/> behind <property name="timeOfCreation" column="TIME_OF_CREATION"/> ,
like this:
<idbag name="userRoles"
lazy="true"
table="USER_ROLE"
order-by="TIME_OF_CREATION asc"
cascade="save-update">
<!-- the surrogate primary key -->
<collection-id column="USER_ROLE_ID"
type="long">
<generator class="increment"/>
</collection-id>
<!-- the foreign key of the User -->
<key column="USER_ID"/>
<!-- a composite-element holding the
associated Role and User, and the
creation time of the link -->
<composite-element class="UserRole">
<!-- an "extra" column -->
<property name="timeOfCreation" column="TIME_OF_CREATION"/>
<!-- for convenience, a backpointer
to the User -->
<parent name="user"/>
<!-- the foreign key of the Role -->
<many-to-one name="role"
cascade="save-update"
outer-join="false"
column="ROLE_ID"/>
<!-- since Roles are cached, disable
outerjoining! -->
</composite-element>
</idbag>
SchemaExportTask failed with infomation
[schemaexport] 21:26:55,000 INFO Environment:432 - Hibernate 2.1.1
[schemaexport] 21:26:55,031 INFO Environment:466 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.hsqldb.jdbcDriver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.ehcache.hibernate.Provider, hibernate.cache.use_query_cache=true, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect, 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=sa, hibernate.hbm2ddl.auto=create, hibernate.connection.url=jdbc:hsqldb:hsql://localhost, hibernate.show_sql=true, hibernate.connection.password=, hibernate.connection.pool_size=5}
[schemaexport] 21:26:55,062 INFO Environment:480 - using java.io streams to persist binary types
[schemaexport] 21:26:55,062 INFO Environment:481 - using CGLIB reflection optimizer
[schemaexport] 21:26:55,156 INFO Configuration:166 - Mapping file: D:\jws\app\adminapp-0.9.2\adminapp-0.9.2\src\java\org\hibernate\admin\model\Role.hbm.xml
[schemaexport] 21:26:56,046 INFO Binder:225 - Mapping class: org.hibernate.admin.model.Role -> ROLE
[schemaexport] 21:26:56,625 INFO Binder:534 - Mapping collection: org.hibernate.admin.model.Role.users -> USER_ROLE
[schemaexport] 21:26:56,687 INFO Configuration:166 - Mapping file: D:\jws\app\adminapp-0.9.2\adminapp-0.9.2\src\java\org\hibernate\admin\model\User.hbm.xml
[schemaexport] 21:26:56,781 ERROR XMLHelper:48 - Error parsing XML: D:\jws\app\adminapp-0.9.2\adminapp-0.9.2\src\java\org\hibernate\admin\model\User.hbm.xml(81) Element "composite-element" does not allow "parent" here.
[schemaexport] 21:26:56,781 INFO Binder:225 - Mapping class: org.hibernate.admin.model.User -> users
[schemaexport] 21:26:57,625 INFO Binder:534 - Mapping collection: org.hibernate.admin.model.User.userRoles -> USER_ROLE
[schemaexport] 21:26:57,640 INFO Binder:534 - Mapping collection: org.hibernate.admin.model.User.roles -> USER_ROLE
[schemaexport] 21:26:57,640 INFO Binder:534 - Mapping collection: org.hibernate.admin.model.User.previousPasswords -> OLD_PASSWORDS
[schemaexport] 21:26:57,687 ERROR Configuration:174 - Could not configure datastore from file: D:\jws\app\adminapp-0.9.2\adminapp-0.9.2\src\java\org\hibernate\admin\model\User.hbm.xml
[schemaexport] net.sf.hibernate.MappingException: invalid mapping
[schemaexport] at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:170)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:195)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:301)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:328)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
[schemaexport] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:377)
[schemaexport] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:135)
[schemaexport] Caused by: org.xml.sax.SAXParseException: Element "composite-element" does not allow "parent" here.
[schemaexport] at org.apache.crimson.parser.Parser2.error(Parser2.java:3354)
[schemaexport] at org.apache.crimson.parser.ValidatingParser$ChildrenValidator.consume(ValidatingParser.java:349)
[schemaexport] at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1497)
[schemaexport] at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
[schemaexport] at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
[schemaexport] at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
[schemaexport] at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
[schemaexport] at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
[schemaexport] at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
[schemaexport] at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
[schemaexport] at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
[schemaexport] at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)
[schemaexport] at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
[schemaexport] at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
[schemaexport] at org.dom4j.io.SAXReader.read(SAXReader.java:339)
[schemaexport] at org.dom4j.io.SAXReader.read(SAXReader.java:219)
[schemaexport] at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:169)
[schemaexport] ... 10 more
BUILD FAILED: D:\jws\app\adminapp-0.9.2\adminapp-0.9.2\build.xml:318: Schema text failed: net.sf.hibernate.MappingException: invalid mapping
I have tried this in hibernate2.1.6 , unfortunately get the similar error !
I want ask if the hibernate must obey the tag order , or this is a bug?