-->
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: Changing mapped table at run time
PostPosted: Thu Jan 13, 2005 9:49 am 
Beginner
Beginner

Joined: Wed Nov 24, 2004 10:54 am
Posts: 48
Hibernate version: 2.1.7

My application hooks up to a legacy database on an AS/400. This database has "Logical files". Logical files are really indexes over the actual table. Becauase of the way SQL works on the AS/400, I have to specifically point my mapping to the logical (index) I want to use.

Here is my question, how do I change the mapping for the table AFTER the Session Factory has already been built? Is that possible? I really do not want to have to rebuild it everytime I need to use a different index.

OR, is there a better way of doing this? Can I have multiple hbm files pointing to the same Java classes for that table?

Any help would be great!

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 13, 2005 4:39 pm 
Regular
Regular

Joined: Tue Jun 22, 2004 8:01 pm
Posts: 106
Location: PowderTown, Utah, USA
I think you can programmatically alter the class mappings by using the SessionFactory.getClassMetadata() method. I've sen postings by Gavin King to this effect in the forums. I know it is possible to alter the metadata, though I've never done it myself. Give that a try and post your results.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 13, 2005 4:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No you can't alter the table name after building the SessionFactory.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 13, 2005 6:26 pm 
Regular
Regular

Joined: Tue Jun 22, 2004 8:01 pm
Posts: 106
Location: PowderTown, Utah, USA
So, you can change some aspects of the mapping, but not the table name?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 13, 2005 6:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No, you can't change anything :) getClassMetadata is all readonly information.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 13, 2005 7:14 pm 
Regular
Regular

Joined: Tue Jun 22, 2004 8:01 pm
Posts: 106
Location: PowderTown, Utah, USA
I remember seeing some posts a while back about changing the characteristics of some part of the mapping... perhaps I was smoking weed at the time?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 14, 2005 10:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you can create a configuration, change it, build a session factory and thats it.

If you want something changed its needed to be done on the configuration and you need to build a new sessionfactory.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 14, 2005 11:06 am 
Beginner
Beginner

Joined: Wed Nov 24, 2004 10:54 am
Posts: 48
Thanks for all the replies, however, I did find an other way. I am working with a lagacy app that runs on an iSeries (AS/400). With V5R2 operating system, they have re-written the "Query Optimizer" This optimizer is what will choose the proper index to use for a specific query. However, there was one peice missing. The "Statistics" for the tables. I had to make some changes in order for the statistics to be captured. The doc said that this was automatic with V5R2. It is, once you turn it on.

Thank Again!


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.