as I wrote earlier I had a problem with the anttask not finding my classes (since separation
of classes/mappinfiles). I'm now using the java task to run the main method of SchemaExport.
To make things easier I added a switch to the commandline where one can specify the
directory which holds the mappingfiles. The switch loads all mappingfiles (ending with .hbm.xml)
to the hibernateconfiguration.
The ant target for creating the ddl would look like:
</target name="createdatabase">
<java classname="net.sf.hibernate.tool.hbm2ddl.SchemaExport" fork="yes">
<arg value="--mappingdir=dir/to/mappingfiles/"/>
<arg value="--quiet"/>
<arg value="--properties=build/hibernate.properties"/>
<classpath refid="classpath"/>
</java>
</target>
Later I might change the ant-task schemaexport as well to have a classpath (which looks like the cleaner solution).
Maybe somebody finds that interesting and will apply that to the hibernate source. This is a patch against
the latest hibernate source from today (a.k.a 2.0.2).
The cvs diff
--- snip
cvs server: Diffing .
Index: SchemaExport.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2ddl/ SchemaExport.java,v
retrieving revision 1.11
diff -r1.11 SchemaExport.java
6a7
> import java.io.File;
277a279,298
> else if (args[i].startsWith("--mappingdir=")) {
> String dir = args[i].substring(13);
> System.out.println("Using mapping dir "+dir);
> File mappingdir = new File(dir);
> String[] children = mappingdir.list();
> if (children == null) {
> // Either dir does not exist or is not a directory
> } else {
> for (int ii = 0; ii < children.length; ii++) {
> // Get filename of file or directory
> String filename = children[ii];
> if (filename.endsWith(".hbm.xml")) {
> cfg.addFile(dir + "/" + filename);
> }
> }
>
> }
> }
>
>
Index: SchemaUpdate.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2ddl/ SchemaUpdate.java,v
retrieving revision 1.9
diff -r1.9 SchemaUpdate.java
4a5
> import java.io.File;
61a63,81
> else if (args[i].startsWith("--mappingdir=")) {
> String dir = args[i].substring(13);
> System.out.println("Using mapping dir "+dir);
> File mappingdir = new File(dir);
> String[] children = mappingdir.list();
> if (children == null) {
> // Either dir does not exist or is not a directory
> } else {
> for (int ii = 0; ii < children.length; ii++) {
> // Get filename of file or directory
> String filename = children[ii];
> if (filename.endsWith(".hbm.xml")) {
> cfg.addFile(dir + "/" + filename);
> }
> }
>
> }
> }
>
------------------------------------------------------- This SF.net email is sponsored by Dice.com. Did you know that Dice has over 25,000 tech jobs available today? From careers in IT to Engineering to Tech Sales, Dice has tech jobs from the best hiring companies. http://www.dice.com/index.epl?rel_code=104 _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel