-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: problem with generating hibernate config file
PostPosted: Sun Jul 09, 2006 4:32 am 
Newbie

Joined: Sun Jul 09, 2006 3:21 am
Posts: 15
i use hibernate tools to create hibernate configuration file
but name of file always are hibernate.cfg.xml .
but i want generate file with another name , help me please .
i use the java code like this :


String srcPath = "srcPath";
String outputPath = "outputPath";


HibernateToolTask t = new HibernateToolTask();

Project project = new Project();
project.setBaseDir(new File(srcPath));

Path p = new Path(project);

p.add(new Path(project, srcPath));
p.add(new Path(project, outputPath));

t.setClasspath(p);

ConfigurationTask ct = t.createConfiguration();

Configuration cfg = ct.getConfiguration();


cfg.setProperty("hibernate.connection.driver_class", "DRIVER");
cfg.setProperty("hibernate.connection.url", "URL");
cfg.setProperty("hibernate.connection.username","USERNAME");
cfg.setProperty("hibernate.connection.password", "pass");

t.setDestDir(new File(outputPath));

t.createHbm2CfgXml();

AntRunner ar = new AntRunner();
ar.runTask(t, srcPath);


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 09, 2006 5:05 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
that's alot of code for such a simple task, eh ? :)

Why are you using ant code and not just ant files ?

and if you were to use code to do it invoking the HibernateConfigurationExporter would be much more sensible.

Anyhow, that exporter does not support changing the output file - put a request in jira and i'll look into it (unless of course someone comes up with a patch for it before me ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.