-->
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.  [ 4 posts ] 
Author Message
 Post subject: Best way to refresh Java Class code generation?
PostPosted: Mon Jan 30, 2006 12:56 pm 
Newbie

Joined: Sun Sep 18, 2005 6:34 pm
Posts: 12
Hibernate version: 3.1.1

Hi,

I am wonder what is the best way to update my java table objects when I change my database model.

I like the fact that I can make changes to my database by altering my mapping xml file and use the "hibernate.hbm2ddl.auto" property in my Hibernate Configuration to push these changes to my database.


Is there a propery that I can set that would also regenerate my java classes to reflect these changes on startup as well? If not please let me know how these updates should be done (ie ... best practices).

Thanks
John


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">pmdev123</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3309/test</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.default_schema"></property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hibernate.hbm2ddl.auto">create</property>

<property name="show_sql">true</property>


<mapping resource="com/portal/model/TerauthUsr.hbm.xml"/>
<mapping resource="com/portal/model/TercrdmUsrGrp.hbm.xml"/>


</session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 2:40 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
hbm2java, in the hibernate tools

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject: How can hbm2java tools be configured/setup
PostPosted: Mon Jan 30, 2006 3:04 pm 
Newbie

Joined: Sun Sep 18, 2005 6:34 pm
Posts: 12
Thanks Chris for your reposnse.... Can I invoke hbm2java from my xml Conf on startup to generate these classes for me automatically?

If seen references in the hiberate documents that say to use an Ant build script.

How are you using it, qand if you are using ant can you provide a sample script?

Thanks Again,
John


Top
 Profile  
 
 Post subject: Re: How can hbm2java tools be configured/setup
PostPosted: Mon Jan 30, 2006 3:12 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
MazzRookie wrote:
Thanks Chris for your reposnse.... Can I invoke hbm2java from my xml Conf on startup to generate these classes for me automatically?

If seen references in the hiberate documents that say to use an Ant build script.

How are you using it, qand if you are using ant can you provide a sample script?

Thanks Again,
John


it is designed to be run from ant which makes it very easy to have it recompile your POJOs on test start, or distribution, or whatever.

I've gotten hbm2java to work the old H2.4 way, I just started trying to get it working using the new h-tools way and haven't gotten it to work yet.

if you search the hibernate-tools forum, there is some information there... as well as the hibernate-tools website :)

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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