-->
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: Version Columns and Reverse Enginering
PostPosted: Sun Dec 31, 2006 4:31 pm 
Newbie

Joined: Wed Nov 29, 2006 2:28 pm
Posts: 12
Hibernate version:3.2

We are using HibernateTools to reverse engineer our DB. Our application uses detached objects with automatic versioning so we need to identify the versioning column in the hibernate mapping file.

The problem I am running into is that every time I reverse engineer, and a new mapping file is created, it wipes out the <version ... /> tag. Is there some way to use Hibernate Tools so I don't have to add these tags back each time?

Are there any other reverse engineering tools out there that would better handle this situation?

thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 5:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Hi Nealc,

I think you will find hibernate tools to be the most complete reverse engineering solution (if not let me know and we will fix that ;)

With respect to version columns then today if you enable optimistic locking detection then columns named VERSION or TIMESTAMP (with the proper types) is automatically marked as <version/> or <timestamp/>

If that does not fit your needs then you can implement a custom ReverseEngineeringStrategy with one of the two methods implemented:

public String getOptimisticLockColumnName(TableIdentifier identifier);

or

public boolean useColumnForOptimisticLock(TableIdentifier identifier, String column);


The first one is to explicit name a column for a certain table and the second one is used when you have optimistic lock autodetection enabled where the reverse engineering will run through all the columns of a table to find it (if any at all).

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 9:14 am 
Newbie

Joined: Wed Nov 29, 2006 2:28 pm
Posts: 12
Thanks.

I agree HibernateTools is the best tool for reverse engineering that I've found.

Am I correct in thinking that in order to implement a custom ReverseEngineeringStrategy I need to use ANT rather than the Eclipse plugin?

Also, we would like to store constants (public static final) in our model files. Values such as MAX_RESULTS or TYPE_LOCAL_USER that relate to a specific column within a specific table. We do not want these values overwritten each time we reverse engineer. Can this be accomplished by implementing a custom ReverseEngineeringStrategy?

Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 10:44 am 
Newbie

Joined: Wed Nov 29, 2006 2:28 pm
Posts: 12
Ah yes, one more thing. :)

Where do I get more information regarding the functionality of the DelegatingReverseEngineeringStrategy and ReverseEngineeringStrategy classes. Is there API documentation available?

Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 12:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
nealc wrote:
Am I correct in thinking that in order to implement a custom ReverseEngineeringStrategy I need to use ANT rather than the Eclipse plugin?


Nope; the eclipse plugin also supports reverse engineering strategy.

Quote:
Also, we would like to store constants (public static final) in our model files. Values such as MAX_RESULTS or TYPE_LOCAL_USER that relate to a specific column within a specific table. We do not want these values overwritten each time we reverse engineer. Can this be accomplished by implementing a custom ReverseEngineeringStrategy?


specific additionas to the code is possible in a couple of different ways:

1) use reveng.xml and put in meta tags for extra-code (or revengstrategy directly and implement tableToMetaAttributes)

2) customize the templates for the java code generation.


With respect to api docs then we should probably include that in the online help.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 1:24 pm 
Newbie

Joined: Wed Nov 29, 2006 2:28 pm
Posts: 12
OK.
How do I indicate to the Eclipse pluging that it should use my custom ReverseEngineeringStategy?

Is there any API documentation on the classes ReverseEngineeringStrategy and DelegatingReverseEngineeringStrategy? Without API documentation it's hard to know where to start.

Thanks again, :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 2:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
The api docs are in the source; just not any public generation of it (yet).

With respect to where to specify the revengstrategy then see this screenshot from the docs:

http://www.hibernate.org/hib_docs/tools ... le/#d0e259

_________________
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.  [ 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.