-->
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: ImprovedNamingStrategy and @Column
PostPosted: Thu Aug 04, 2011 10:51 am 
Newbie

Joined: Thu Aug 04, 2011 10:41 am
Posts: 4
Hi,
I am using a custom naming strategy which extends com.hibernate.cfg.ImprovedNamingStrategy to format my field names.
There are instances however where I would like to specify the exact column name that I wish to generate in the database and therefore use the column annotation.
However the name that I specify in the annotation is still passed to the naming strategy and so if I use a mixed case column name e.g. columnName I end up with column_Name.
I expected @Column to overwrite any calls to a naming strategy.
Is there a work around for this?
Thanks,
Barry


Top
 Profile  
 
 Post subject: Re: ImprovedNamingStrategy and @Column
PostPosted: Fri Aug 05, 2011 3:46 am 
Newbie

Joined: Thu Aug 04, 2011 10:41 am
Posts: 4
After a bit more looking about I believe I have the solution. I was only overriding the methods:
Code:
    public String classToTableName(String className)
    public String propertyToColumnName(String propertyName)
    public String joinKeyColumnName(String joinedColumn, String joinedTable)
    public String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName)


in my implementation.

It appears that where there is an explicit naming of an column or table the methods:

Code:
   public String columnName(final String columnName)
   public String tableName(final String tableName)

are called respectively.

In this case I just need to override these methods and return the same passed parameter.
Cheers,
Barry


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.