I've managed to get the schema export off the ground and it works fine. I have a question.
After doing more digging around, I found that I should replace
Code:
<schemaexport properties="${class.root}/hibernate.cfg.xml"
with
Code:
<schemaexport config="${class.root}/hibernate.cfg.xml"
When I ran my ant script, I saw:
Code:
[schemaexport] 23:49:22,419 INFO Configuration:169 - Mapping file: C:\eclipse\workspace\vinyl\classes\Record.hbm.xml
[schemaexport] 23:49:22,466 ERROR Configuration:255 - Could not compile the mapping document
[schemaexport] net.sf.hibernate.MappingException: duplicate import: Record
[schemaexport] at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
So it's as if the export tool was trying to generate the source for Record.hbm.xml twice.
hibernate.cfg.xml mentions Record.hbm.xml like so:
Code:
<mapping resource="Record.hbm.xml" />
My ant script also refers to *.hbm.xml:
Code:
<taskdef name="schemaexport"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="project.class.path" />
<schemaexport config="${class.root}/hibernate.cfg.xml"
quiet="no"
text="yes"
drop="no"
delimiter=";"
output="${source.root}/schema.sql">
<fileset dir="${class.root}">
<include name="**/*.hbm.xml" />
</fileset>
</schemaexport>
I can get the export to work properly is if I change my ant script to
Code:
<fileset dir="${class.root}">
<include name="**/*.hbm.BLAH" /> <-- *note -->
</fileset>
as if to make the tool "ignore" Record.hbm.xml that's copied into the /classes folder.
Can anyone see why that is so?
-Rob