-->
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: H-tools, reveng, JPA: FK is not mapped after the column name
PostPosted: Tue Oct 06, 2009 10:49 am 
Newbie

Joined: Tue Oct 06, 2009 10:37 am
Posts: 2
Hello,

is it possible the setter/getter generated for a FK mapping to be named after the name of the (parent)column and not after the name of the (child)table? For example, I have a PERSON table and an ADDRESS table and a FK from ADRESS to PERSON which I keep on a column 'homeAddress' in PERSON table. On my JPA mappings for Person.java I would expect to see something like 'setHomeAddress' (i.e. after the name of the parent-column), however I see a 'setAddress' (i.e. after the name of the child-table-name).

I understand I can customise the above on my reveng.xml with <foreign-key> directives for each of my tables, however I am wondering whether I can avoid spending all those extra hours for something so trivial.


thanks!


Top
 Profile  
 
 Post subject: Re: H-tools, reveng, JPA: FK is not mapped after the column name
PostPosted: Wed Oct 07, 2009 7:59 am 
Newbie

Joined: Tue Oct 06, 2009 10:37 am
Posts: 2
Well, to answer my own question, on a custom Reverse Engineering strategy class:

Code:
public String foreignKeyToEntityName(String keyname, TableIdentifier fromTable, List fromColumnNames, TableIdentifier referencedTable, List referencedColumnNames, boolean uniqueReference) {
                String retVal = delegate.foreignKeyToEntityName(keyname, fromTable, fromColumnNames, referencedTable, referencedColumnNames, uniqueReference);
       
                if (fromColumnNames.size() == 1) {
                    Column c = (Column)fromColumnNames.get(0);
                    retVal = toUpperCamelCase(c.getName());
                    retVal = retVal.substring(0, 1).toLowerCase() + retVal.substring(1);
                }
                       
                return retVal;       
    }


However if you happen to have compound FKs, then you need to iterate over the list of column names.


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.