-->
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.  [ 2 posts ] 
Author Message
 Post subject: hibernate 4.2 schema based multitenancy c3p0 connection pool
PostPosted: Mon Apr 08, 2013 10:02 am 
Newbie

Joined: Sun Apr 07, 2013 3:38 pm
Posts: 3
I am running a java app (java 1.7) with hibernate 4.2.0 and I need to implement a schema based multi tenancy setup. I used this example:

https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java

to do that. my problem is that I was unable to figure out how to create the connection providers. the example uses:

Code:
    acmeProvider = ConnectionProviderBuilder.buildConnectionProvider( "acme" );
    jbossProvider = ConnectionProviderBuilder.buildConnectionProvider( "jboss" );


but ConnectionProviderBuilder is for testing use.

I tried to use the following:

Code:
    C3P0ConnectionProvider connectionProvider = new C3P0ConnectionProvider()
    {
        public boolean supportsAggressiveRelease()
        {
            return allowAggressiveRelease;
        }
    };

    connectionProvider.configure(props);


the problem here was that the C3P0ConnectionProvider has a null serviceRegistry which crush the with NPE.

does anyone have an idea on how to create ConnectionProvider for each tenant?

Thanks,

Ronen


Top
 Profile  
 
 Post subject: Re: hibernate 4.2 schema based multitenancy c3p0 connection pool
PostPosted: Fri May 17, 2013 7:19 am 
Newbie

Joined: Tue Aug 28, 2007 12:54 pm
Posts: 16
Location: Munich, Germany
Having an existing DataSource (from a AS7 app server JNDI registry in my case, but you can surely get one wihtout that), the following works for me:
Code:
DatasourceConnectionProviderImpl cp = new DatasourceConnectionProviderImpl();
cp.setDataSource(ds);
Properties p = new Properties();
// ...
cp.configure(p);

No idea if this is recommended, legal, ... any further input appreciated.

_________________
www.tomeicher.de


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.