-->
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.  [ 9 posts ] 
Author Message
 Post subject: Changing schema names with annotations
PostPosted: Tue Jun 05, 2007 10:32 am 
Newbie

Joined: Tue Jun 05, 2007 10:09 am
Posts: 2
I have an application which operates on two separate database schemas in an Oracle database. On one of my deployment sites these schamas have different names than in my development environment, creating a need for me to dynamically reasign the schema names for all tables.

As long as I was using .hbm.xml files to declare my mappings I did this by creating my own SessionFactory, which overrode the postProcessConfiguration() method. This enabled me to get to the class mappings by calling Configuration.getClassMappings and change the schema for each mapping.

Now I've started to use annotations to declare my mappings, and this causes several problems.

Firstly, my custom SessionFactory must extend AnnotationSessionFactoryBean. This class has made the postProcessConfiguration() method final, so I can no longer override it. I've solved this by overriding the postProcessAnnotationConfiguration() method in stead.

But the really big problem is that Configuration.getClassMappings() no longer returns any mappings. I can see that there are annotatedClasses inside the AnnotationConfiguration object, but there is no "getAnnotatedClasses" method. So I can't access them.

My qestiong therefore is: How can I get to the annotated classes and change the schema for each entity?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 05, 2007 5:51 pm 
Newbie

Joined: Tue May 08, 2007 3:34 pm
Posts: 19
I don't know if this will help in any way, but I have an application that requires 39 different schemas. Therefore, I needed to setup the connection using a dynamic approach passing in the user, password, and schema. I am not using annotations, so I am not really sure about any of that. Let me know if I can try and give any help with my solution.


Top
 Profile  
 
 Post subject: Dynamic Schema allocation
PostPosted: Tue Jun 05, 2007 11:41 pm 
Newbie

Joined: Tue Jun 05, 2007 11:22 pm
Posts: 1
I have a similar, yet different problem. Our application requires accessing a number copies of a common table (each with different data) that exists under different schema owners eg.

FRED.MY_TABLE
JOE.MY_TABLE
CHARLIE.MY_TABLE

We would like to have the one pojo / table mapping , but be able, at runtime, to change the schema owner. Alternatively we could name them differently via a synonym eg.

FRED.MY_TABLE becomes MY_TABLE_FRED

but in either case we would like to change the schema owner or table name at runtime.

I am aware that we could try and change some of the Configuration Mapping via the Configuration and generate a new SessionFactory but we would need to do this for every schema owner.

Can we dynamically set the schema owner or object name just at the point that we process the query and then be able to reassign it continually without having to create a newSessiinFactory for each type of schema owner ??

TIA


Top
 Profile  
 
 Post subject: jruss1012 , i didnt understand how you work with multiple
PostPosted: Wed Jun 06, 2007 1:04 am 
Regular
Regular

Joined: Wed May 02, 2007 2:42 pm
Posts: 101
schema ?

I need in my application to work with the same mappings to unbounded number of schema.
The user can ask in run-time to assign his work to another schema.

I didnt find a way to obtain new factory to another schema ( and still have the old factory , because i need it to another user ).

Do you work with DS?
Do you map the DS to the schema url or to the DB url?
How you create new factory for new schema at run time?


Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 06, 2007 12:03 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Why don't you use
Code:
hibernate.default_schema
?

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Can you please explain how it can help me?
PostPosted: Wed Jun 06, 2007 12:54 pm 
Regular
Regular

Joined: Wed May 02, 2007 2:42 pm
Posts: 101
I have a group of entity that i need to work with them in differents schemas.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 06, 2007 1:03 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/ then search for the property name :)

_________________
Emmanuel


Top
 Profile  
 
 Post subject: It isnt enable you in run time to change the schema
PostPosted: Wed Jun 06, 2007 1:57 pm 
Regular
Regular

Joined: Wed May 02, 2007 2:42 pm
Posts: 101
I am talking about JPA in JBoss.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 07, 2007 9:44 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
JPA in JBoss is Hibernate

_________________
Emmanuel


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