-->
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.  [ 8 posts ] 
Author Message
 Post subject: Central configuration for mappings?
PostPosted: Sat Dec 18, 2004 7:32 pm 
Newbie

Joined: Sat Dec 18, 2004 7:29 pm
Posts: 4
I am developing a framework that uses hibernate for persistence. I am trying to figure out a way to have a central config for attributes in the hbm.xml files. For example, I would like to be able to change all the table/column names without having to edit the hbm.xml files in the framework. Any best practices? Thoughts?

-Anthony


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 19, 2004 6:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
and NamingStrategy is not what you want ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 19, 2004 12:59 pm 
Newbie

Joined: Sat Dec 18, 2004 7:29 pm
Posts: 4
max wrote:
and NamingStrategy is not what you want ?


NamingStrategy is not what I was looking for. NamingStrategy (and corrent me if I am wrong) looks to be a method for doing things like appending a prefix to table/column names and other such tasks.

What I want to do with the framework I am developing is not force table/column names the others that may use this framework. For example I may call a table "usr" and someone else may want to name the table "organization_user" or if the person speaks a different language than myself they may want to have all the table/column names in thier native language. I want to do complete substitutions. Without wading through the hbm.xml files it would be nice to have a single properties file that could hold all of this such as:

table.user.name=USER
table.company.name=COMPANY

Makes sense? Any thoughts?

-Anthony


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 19, 2004 1:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You can easily write some code that manipulates the net.sf.hibernate.mapping metamodel.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 19, 2004 1:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes - you are right about the *intended* usage of NamingStrategy but what is the problem with having a NamingStrategy that reads your propertyfile and returns column and table names based on that ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 19, 2004 6:40 pm 
Newbie

Joined: Sat Dec 18, 2004 7:29 pm
Posts: 4
max wrote:
yes - you are right about the *intended* usage of NamingStrategy but what is the problem with having a NamingStrategy that reads your propertyfile and returns column and table names based on that ?


ahhh! I was looking at NamingStrategy in the Hibernate Reference when you first mentioned this and it did not make clear how this could be used. After you posted back I opened up "Hibernate in Action" and the javadocs and see there is a bit more to this. Thank you for pointing out the solution twice :)

-Anthony


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 20, 2004 4:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
tip for future reference: Look in the source - normally much faster ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Class name reference when naming column
PostPosted: Thu Sep 01, 2005 1:55 pm 
Newbie

Joined: Sat Jul 30, 2005 9:22 pm
Posts: 3
Location: Pennsylvania, USA
I have a case where I want to name all my primary key columns to '<table_name>_id' instead of 'id' to avoid ambiguity. Since I am already implementing a NamingStrategy to convert camelCase to underscores as in ImprovedNamingStrategy, I wanted to attempt to automatically create enhanced primary key column naming too.

Looking at the NamingStrategy Interface and the ImprovedNamingStrategy implementation, I don't see that it is possible to obtain a reference to the parent class/table name of the current property. Am I correct in this observation? Has anyone else attempted to do this?


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