-->
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.  [ 1 post ] 
Author Message
 Post subject: Multitenancy with Schema using Spring and Hibernate
PostPosted: Fri May 16, 2014 5:11 am 
Newbie

Joined: Mon Mar 11, 2013 1:02 pm
Posts: 5
Hi group -

I am trying out a simple Schema based Multitenancy using Single Datasource.

Did configure
Code:
                <prop key="hibernate.multiTenancy">SCHEMA</prop>
                <prop key="hibernate.multi_tenant_connection_provider">org.dao.MultiTenantConnectionProviderForSchema</prop>
                <prop key="hibernate.tenant_identifier_resolver">org.dao.MultiTenantResolver</prop>


and I am trying to set the schema using the connection with set SCHEMA 'tenantid' in the MultiTenantConnectionProviderForSchema class.

Getting struck here, as i am not able to inject the datasource into the @component class, eventhough it is autowired

Has anyone resolved it?


Below is my beans.xml

Code:
<context:component-scan base-package="org.dao"/>
   <context:annotation-config />
   
       
   <bean name="dataSource" id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="org.postgresql.Driver" />
      <property name="url" value="jdbc:postgresql://localhost:5432/postgres" />
      <property name="username" value="postgres" />
      <property name="password" value="root" />
   </bean>

   <bean name="sessionFactory"
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
      <property name="dataSource" ref="dataSource"></property>
      <property name="packagesToScan" value="org.entity"/>
      <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
                <prop key="hibernate.multiTenancy">SCHEMA</prop>
                <prop key="hibernate.multi_tenant_connection_provider">org.dao.MultiTenantConnectionProviderForSchema</prop>
                <prop key="hibernate.tenant_identifier_resolver">org.dao.MultiTenantResolver</prop>
            </props>
        </property>
   </bean>

   <bean name="NodeDAO" class="org.dao.NodeDAO">
      <property name="sessionFactory" ref="sessionFactory"/>
   </bean>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.