Hello,
Well, I am doing an application where I must execute an *.bat. I musn't use Ant although I can use its jars.
The *.bat contains a
java -classpath ...
command, that must do:
-Call the middlegen task, using only the hibernate plugin and a velocity template (with a fileproducer?) that allows me to avoid associations. This is the most difficult thing because calling a task in my code is easy but using the hibernate plugin and the template, mmm, I don't know what I should do yet.
The middlegen task generates the *.hbm.xml files I need.
-Call the hbm2java task that uses the *.hbm.xml fileset and generates the *.java. I have already done it. It was in short:
Code:
...
Hbm2JavaTask task = new Hbm2JavaTask();
FileSet fSet = new FileSet();
fSet.setDir(srcDir);
fSet.setCaseSensitive(false);
FilenameSelector fNameSelector = new FilenameSelector();
fNameSelector.setCasesensitive(false);
fNameSelector.setName("*.hbm.xml");
fSet.addFilename(fNameSelector);
fSet.setProject(pr);
task.addFileset(fSet);
task.setOutput(outputDir);
task.execute();
...
Although I had to compile two Ant classes and generate again ant.jar because when calling log() from class 'Project', unusual exceptions were thrown. Then all worked.
-After that, the *.java must be compiled during runtime, calling the main() method from the class 'Javac', or something like that.
-Finally I can call the get() and set() methods from the different classes at my will. Why? My application is used to retrieve and save data from a database but must be useful for every database (not for a specific schema) so I must generate and compile hibernate persistent classes during runtime. I just want to retrieve and save data and I am not interested in associations.
Any idea for the middlegen task?
Thanks and kind regards,
Jose Luis