-->
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.  [ 6 posts ] 
Author Message
 Post subject: Fully qualified entity name for naming tables
PostPosted: Tue Feb 20, 2007 1:07 pm 
Newbie

Joined: Tue Feb 20, 2007 12:37 pm
Posts: 4
I'm trying to write a good (for me) naming strategy, but I'd like to use the name of the packages involved in the class, to make a table. For instance, the entity com.example.project.entities.exampledata shoud make a table named PROJ_ENTI_EXAMPLEDATA or something similar, from now it's just string manipulation.

The problem is that the NamingStrategy classes only get the unqualified class name to work with, so there is no way I con do it just configuring a custom NamingStrategy class.

I found that the only place to change would be in org.hibernate.cfg.annotations.EntityBinder, line 353 (version 3.2.1.GA of hibernate-annotations), in function getClassTableName, where
Code:
return mappings.getNamingStrategy().classToTableName( name );
can be changed to
Code:
return mappings.getNamingStrategy().classToTableName( annotatedClass.getName() );
to do the trick.

But that would be hacking the code, instead I just want to override the code in EntityBinder, and configure the server to use my custom binder.

Any idea about how and where to configure the binder???

Thank you for taking the time to read!

Saverio


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 20, 2007 1:15 pm 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
I assume you do not want to do this in a static/hardcoded way, but if you did you could annotate your Entities with:

Code:
@Table(name="<your table name>")


Cheers,

Andy

_________________
Rules are only there to be broken


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 20, 2007 1:19 pm 
Newbie

Joined: Tue Feb 20, 2007 12:37 pm
Posts: 4
:)

Of course, when you have a couple of entities, this should be a good strategy. Now imagine a large project with hundreds of entities, and just in that moment of development when the packages are changing constantly depending on your boss's good will.... !!!refactoring hell!!!

I am hoping for a solution that can stand the attack of the evil refactorer! That is, no explicit naming AT ALL.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 20, 2007 8:13 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Can you open a JIRA issue, I can't really do it in a 3.2.x series, but I can slip it in 3.3

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 21, 2007 4:59 am 
Newbie

Joined: Tue Feb 20, 2007 12:37 pm
Posts: 4
Thanks Emmanuel for the quick answer. It's good to know that we have reached the actual limits of the software instead of the limits of our vision. I'll try to post it to JIRA as soon as possible. Also it's good that this issue has deserved an archangel's answer in the earliest place!!! It's just like when in the faculty the big guy at the other side of the room says "Good question!".



On the other side, when is the new release (3.3) supposed to exist? That is, if there is a timespan of few (4 or 5) months, maybe I'll wait for the new version to deploy the database, if more, then I'll look for another way (either simple prefixing via NamingStrategy or explicit naming of every table via XML).

Best regards.

Saverio


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 21, 2007 6:59 am 
Newbie

Joined: Tue Feb 20, 2007 12:37 pm
Posts: 4
Issue opened:

http://opensource.atlassian.com/projects/hibernate/browse/ANN-561

I hope that someone will soon take on the coding!

Good work to everyone!


Saverio


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