-->
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.  [ 7 posts ] 
Author Message
 Post subject: Using Hbm2JavaTask from Application
PostPosted: Thu Oct 06, 2005 10:12 am 
Newbie

Joined: Tue Sep 27, 2005 10:12 am
Posts: 9
Hi All,
In Hibernate3 version how to use Hbm2JavaTask from my application ie. outside build.xml.
I could do this for SchemaExport / SchemaUpdate.But for Hbm2JavaTask I could not find any document telling how to go about.
Experts need your help
Regards
Vasu


Top
 Profile  
 
 Post subject: Re: Using Hbm2JavaTask from Application
PostPosted: Sat Oct 08, 2005 2:08 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
tkvasu wrote:
how to use Hbm2JavaTask from my application ie. outside build.xml.

exporter = new org.hibernate.tool.hbm2x.POJOExporter()
// setter injections
exporter.start();

see the source under org.hibernate.tool.test for examples on how to do this.


Top
 Profile  
 
 Post subject: Didn't succede to run it from application
PostPosted: Tue Nov 29, 2005 12:41 pm 
Regular
Regular

Joined: Tue Nov 29, 2005 12:31 pm
Posts: 75
I've tried to use POJOExporter and I'm receiving NullPointerException.

Exception in thread "main" java.lang.NullPointerException
at org.hibernate.tool.hbm2x.VelocityProducer.putInContext(VelocityProducer.java:89)
at org.hibernate.tool.hbm2x.VelocityProducer.firstPass(VelocityProducer.java:69)
at org.hibernate.tool.hbm2x.VelocityProducer.produce(VelocityProducer.java:27)
at org.hibernate.tool.hbm2x.VelocityProducer.produce(VelocityProducer.java:104)
at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:112)
at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(GenericExporter.java:100)
at org.hibernate.tool.hbm2x.GenericExporter.exportClasses(GenericExporter.java:83)
at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:68)

I'm using HibernateTools-3.1.0.beta1.

Any ideas ? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 12:44 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
can you post the relevent java for this?


Top
 Profile  
 
 Post subject: Java code 4 POJOExporter
PostPosted: Wed Nov 30, 2005 4:09 am 
Regular
Regular

Joined: Tue Nov 29, 2005 12:31 pm
Posts: 75
Here is the fragment code.



Configuration cfg = new Configuration();
cfg.configure(“the file path to hibernate.xml”);

File file = new File("C:\temp");

POJOExporter pojoExporter = new POJOExporter(cfg, file);
System.out.println(pojoExporter.getTemplateName()); // prints “Pojo”
pojoExporter.doStart();


My hibernate.cfg.xml file contains one mapping resource well defined (I was able to run SchemaExport on it).

If you want more details please ask.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 4:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
why would you call doStart() ?


start() would be a much better method ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 4:36 am 
Regular
Regular

Joined: Tue Nov 29, 2005 12:31 pm
Posts: 75
Because I don't have a home, a house, a girlfriend, enought money ... ;)

Of course I didn't pay attention to the details, now works very well.

Thanks and best.[/img]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.