-->
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 parameterize the DefaultNamingStrategy
PostPosted: Tue Aug 16, 2016 3:35 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2010 3:35 pm
Posts: 37
when using the DefaultNamingStrategy to map an entity with multiple identical tables, but with different suffixes as per below,

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

few questions,

1) The parameter 'yearSuffixTable' - how is it being passed to the naming strategy implementation? i assume its a member variable that is being populated when required is that right and that the value is not hardcoded?

2) when exactly its value [ 'yearSuffixTable'] is being set? Is it at application start up or at run time ?
do we need to know all possible year suffixes and create a naming strategy for each one of them (hardcoded) during the application start up itself or have one naming strategy implementation with the 'yearSuffixTable' parameter and the value of the parameter be set at run time ?

3) does one need to create the hibernate session at application start up for each of those naming strategy combinations (year suffixes) at application start up and cache it or we can do it at run time when needed? any advantage between the two apart from the creation time.

please share (if any) code samples to understand it better, thanks.


regards
aravias


Top
 Profile  
 
 Post subject: Re: DefaultNamingStrategy - how to set the value of the param
PostPosted: Mon Aug 29, 2016 3:12 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
1) For that StackOverflow question, I guess the value for yearSuffixTable was supplied to the NamingStartegy upon instantiation when bootstrapping the SessionFactory.

2) You can also make that dynamic and load it from a properties file or something like that, it does not need to be hardcoded.

3) The Session is created automatically from the SessionFactory. The SessionFactory si created once the application bootstraps and it will use one and only one NamingStartegy, so no need for caching here.


Top
 Profile  
 
 Post subject: Re: How to parameterize the DefaultNamingStrategy
PostPosted: Mon Aug 29, 2016 1:13 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2010 3:35 pm
Posts: 37
1) reading it from properties (the value for parameter 'yearSuffixTable') is fine, but I am trying to set this value later at run time after the application has actually started, session factory has been created etc , subsequently based on some user selected value ?

just to give some more info related to this. There is an UI currently where users can generate reports based on many search criteria's and date range is one of them. Currently, all data spanning many years reside in one table and it takes lot of time to generate reports. we cannot purge records due to policies. Between table partitioning and creating archive tables, after some consideration between those 2 we decided to create archive tables with each storing 5 years of data. Related to this, when the user searches now, based on the date range we need to identify dynamically which archive table to retrieve the data from and then fetch the data. Assuming I know which table suffix to retrieve data from , how to set this value in the naming strategy parameter at this point so that the queries ran after that fetch from the right archive table?


2) I was also considering below approach apart from the naming strategy , but sounds like more work

https://coderanch.com/t/492558/ORM/data ... ernate-XML


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.