-->
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: How to control composite key names when reverse engineering
PostPosted: Wed Mar 31, 2010 2:37 pm 
Newbie

Joined: Wed Feb 18, 2009 5:19 pm
Posts: 5
Hi, I am trying to use Hibernate tools for Eclipse version 3.2.4, to reverse engineer an Oracle schema. This is a legacy system that used Middlegen in the past to generate pojo for our persistence objects.

My current problem is that Hibernate tools is creating composite keys and naming them ‘id’. I would like them to be named ‘comp_id’. This is what our existing code is expecting but can’t find how to do this.

How can I force Hibernate tools to give all composite keys a name of ‘comp_id’ instead of ‘id’? Is this possible to do automatically for all tables with composite keys or do I have to specify a Table element for each table in the reverse engineering strategy file or is there some other way to accomplish this?

Thanks for your help.
Tom


Top
 Profile  
 
 Post subject: Re: How to control composite key names when reverse engineering
PostPosted: Tue Apr 13, 2010 2:20 pm 
Newbie

Joined: Wed Feb 18, 2009 5:19 pm
Posts: 5
Since no one answered me I will post what I used as a solution to this problem in case someone else has a similar issue.

I ended up creating my own version of these template files:

PojoConstructors.ftl, PojoFields.ftl and PojoPropertyAccessors.ftl.

In each I checked if the property name is equal to 'id' and if so, changed it to the name I want, 'comp_id' using something like this throughout.

<#if property.name.equals("id")>

I'm not sure if this is the best way to do this or even the only way to do this but it seems to have worked for me in this case.


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.