-->
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.  [ 3 posts ] 
Author Message
 Post subject: Better naming strategy
PostPosted: Mon Nov 23, 2009 6:06 am 
Newbie

Joined: Tue Mar 08, 2005 9:09 am
Posts: 8
Location: Munich
Hi,

I have stumbled upon the same problem multiple times in the last years so I finally decided to ask for a solution here. I have often had requirement to prefix column names for persistent classes to names which include the table name in some form as a prefix. For example the class could look like this:
Code:
class Requests {
  long id;
  String name;
}

and should be mapped to a relation named T_REQUESTS with columns REQ_ID and REQ_NAME (tableName := "T_" + camelToUpperUnderscoreCase(className); columnName := className.substring(0,3) + "_" + camelToUpperUnderscoreCase(propertyName)). This is unfortunately impossible (AFAIK) using the current NamingStrategy interface which does not provide the class name to the method which must determine the name of the column. Is there another way to achieve this (in an automated fashion and not by specifying each name)? Do you plan to enhance the naming strategy with this data which is available in the caller of naming strategy?

Best regards,
Dimo


Top
 Profile  
 
 Post subject: Re: Better naming strategy
PostPosted: Mon Nov 23, 2009 10:04 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
hmm, normally classes properties are named after the classes table is named. So you could store the last parameter of a classToTableName-call and use it in propertyToColumnName.

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject: Re: Better naming strategy
PostPosted: Mon Nov 23, 2009 6:23 pm 
Newbie

Joined: Tue Mar 08, 2005 9:09 am
Posts: 8
Location: Munich
Yes, maybe. However, there is no contract that it really is used that way and it would be pretty ugly to have an instance property in the naming strategy holding the last mapped class name.


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