-->
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: How to map a table name dynamically
PostPosted: Mon Aug 08, 2016 4:30 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2010 3:35 pm
Posts: 37
Hi,
we have similar set of tables with different suffixes in their names differentiating them everything else remaining identical for storing historical data, looking for a way to have an entity mapped to these set of tables and have the table name to be resolved dynamically at run time. I came across below,

http://stackoverflow.com/questions/8573 ... nnotations

if there is any other option in recent times/suggestions please share. Our hibernate version is 4.3

regards
aravias


Top
 Profile  
 
 Post subject: Re: dynamic-table-name
PostPosted: Tue Aug 09, 2016 1:32 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
If you're using 4.3, you can achieve this goal by using a custom NamingStrategy as explained in that StackOverflow answer.

For Hibernate 5, you need to extend PhysicalNamaingStrategy, like in this example (which changes the column name). The PhysicalNamingStrategy allows you to customize the table name with the toPhysicalTableName methods.


Top
 Profile  
 
 Post subject: Re: dynamic-table-name
PostPosted: Tue Aug 09, 2016 12:23 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2010 3:35 pm
Posts: 37
thanks for the details.


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.