-->
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.  [ 4 posts ] 
Author Message
 Post subject: PostgreSQL schemas auto generation
PostPosted: Mon Jan 30, 2006 11:31 pm 
Newbie

Joined: Thu Dec 01, 2005 11:48 pm
Posts: 8
Hi there,

I am using Hibernate with PostgreSQL 8.0 and want to achieve the following:

In my web application I want to use a different postgre schema for every new customer. I then use a different SessionFactory for every schema setting the hibernate.default_schema property. Do you think this is agood approach or is there a way to do this with one SessionFactory?

sadly hibernate's hbm2ddl (set to 'create') doesn't create the schemas automatically. as a workaround I now open a jdbc connection "by-hand" and create the schema with an SQL statement. it would just be nice to have hibernate do it. does anyone know how to accomplish this?

thx

max


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 31, 2006 3:23 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
Hello you can set Hibernate properites by hand. I think in the reference there is an example.
You will probably need an Factory around your standard HibernateSessionFactory providing the SchemaHibernateSessionFactory.

Have a look in the Schema generation source. It is probably a simple fix.

Regards Sebastian

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject: more trouble
PostPosted: Mon Feb 06, 2006 7:08 am 
Newbie

Joined: Thu Dec 01, 2005 11:48 pm
Posts: 8
thx for your help,

what i am actually doing is creating a new SessionFactory for each schema and organize the whole thing in a HashMap<String, SessionFactory>.
I wrote a method in a Singleton class that adds new SessionFactories to the HashMap.
Then I request a session from by getting the SessionFactory from the HashMap and requesting openSession() on the selected SessionFactory.

What do you think of this approach?

I think hacking the schema creation code is a bit too much for me at my current knowledge of Hibernate. If anyone else is able to it and will give a helping hand as much as I can.

Cheers

Max


Top
 Profile  
 
 Post subject: another thing
PostPosted: Mon Feb 06, 2006 7:33 am 
Newbie

Joined: Thu Dec 01, 2005 11:48 pm
Posts: 8
another thing I just found out that relates to the topic:

if you use numbers (e.g. "123") for your schemas then hbm2ddl doesn't do anything (e.g. creating sequences or tabels).

sadly this isn't related to not creating the schema itself as mentioned above which isn't working with a alphanumerical string (e.g. "abc") as well.

just wanted to let you(whoever may read it) know.

cheers

max


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