-->
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: Urgent - Changing schema during transaction
PostPosted: Fri Feb 09, 2007 3:38 pm 
Newbie

Joined: Tue Mar 30, 2004 9:58 am
Posts: 8
Location: Chicago, IL
Hello,
We have an unique situation. We have adentical tables under diffrent schemas. We have a schema for each customer. When a message arrives from a customer, depending on the messge origin (customer) we store the message in the appropriate table in the appropriate schema belonging to the customer.

I tried the following:
Configuration cfg = this.sessionFactoryBean.getConfiguration();
PersistentClass pc = cfg.getClassMapping("com.vibes.aggregator.service.routing.model.MtShortMessage");

Table table = pc.getTable();
table.setSchema("client_11");

getHibernateTemplate().merge (mtShortMessage);

But, every time I do this the data gets saved in the original schma.

Any help would be appreciated!


Thanks
Matt

_________________
Matt Madhavan, Consultant


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 09, 2007 5:00 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
you have to recreate the SessionFactory for those changes to be take effect. You can't change it on the fly.

Might wanna use 2 session factories, one for each schema, and just pick and choose as needed.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 09, 2007 5:13 pm 
Newbie

Joined: Tue Mar 30, 2004 9:58 am
Posts: 8
Location: Chicago, IL
Hi Chris,
I need something more dynamic than this. I am looking for something equivalnt to,

For customer_1
select * from customer_1.messages

For Customer_1
select * from customer_2.messages

Where customer_1 and customer_2 are postgress schemas and messages being idenitical tables in two different schemas.

In our system the customer base is very dynamic!

Any help will be appreciated!

Thanks
Matt

_________________
Matt Madhavan, Consultant


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.