Hi,
I'm working with Tomcat5 & Hibernate3 and I have a web application that receives a java source file, generates it's mapping file (".hbm.xml") & it's database schema with SchemaExport.
The code of database schema generation is:
public static void generateSchema(){
//loads hibernate.cfg.xml into "config"
loadConfiguration();
//loads current session
Session s = currentSession();
Transaction tx = null;
try {
SchemaExport schemaExport = new SchemaExport(config);
schemaExport.create(true, true);
tx = s.beginTransaction();
tx.commit();
}
catch (Exception e) {
e.printStackTrace();
try {
tx.rollback();
}
catch (HibernateException e1) {
e1.printStackTrace();
}
}
finally{
closeSession();
}
}
It works!! But there is a little problem. It generates schemas for all mapping files contained in hibernate.cfg.xml.
Is there any way to generate the schema for a single mapping file?
If you can't answer me, do you kwow where is the SchemaExport source documentation?
Thanks.
|