[hibernate-dev] Hibernate 4 Multi-tenancy Issue - No Entity Persisters Found

Jitu abjitu at gmail.com
Wed Jul 1 13:06:53 EDT 2015


I have tried hibernate 4 multi-tenancy with Spring. Please check if this
helps you in anyway https://github.com/abjitu/multitenancy

On Wed, Jul 1, 2015 at 10:35 PM, Jitu <abjitu at gmail.com> wrote:

> As per the exception. it looks like hibernate is not not able to find
> querytranslator which means hibernate is not able to translate HQL query to
> SQL query. So increase log level to TRACE and provide more logs.
>
>
> On Wed, Jul 1, 2015 at 1:08 PM, amit shah <amits.84 at gmail.com> wrote:
>
>> Hello,
>>
>> I have been trying to integrate hibernate 4 multi-tenancy support in our
>> application but I get the below exception on executing an hql query
>>
>> java.lang.ArrayIndexOutOfBoundsException: 0
>>     at
>> org.hibernate.jpa.spi.AbstractEntityManagerImpl.resultClassChecking(AbstractEntityManagerImpl.java:362)
>>     at
>> org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:344)
>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>     at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>>     at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>     at
>> org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:344)
>>     at com.sun.proxy.$Proxy288.createQuery(Unknown Source)
>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>     at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>>     at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>     at
>> org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:291)
>>     at com.sun.proxy.$Proxy43.createQuery(Unknown Source)
>>
>> The hql query is -
>>
>> List<Field> fields = entityManager.createQuery("from " +
>> Employee.class.getName() +
>>                     " where " + getQueryForInClause("id", ids),
>> Employee.class).getResultList();
>>
>> On debugging hibernate source, I realize that this is because
>> hibernate's *SessionFactory
>> instance does not have any entityPersister instances* due to which the hql
>> query does have any translator's.
>>
>> Is it because the Entity beans are not getting scanned? If so what could
>> be
>> the cause?
>>
>> The entityFactory spring is declared as below
>>
>> <property name="persistenceProviderClass"
>> value="org.hibernate.jpa.HibernatePersistenceProvider"/><property
>> name="persistenceXmlLocation"
>> value="/com/software/persistence/persistence.xml"/><property
>> name="jpaProperties">
>>     <map>
>>         <entry key="hibernate.id.new_generator_mappings" value="true"/>
>>         <entry key="hibernate.cache.use_second_level_cache"
>> value="false"/>
>>         <entry key="hibernate.dialect"
>> value="com.software.persistence.ExtendedOracle10gDialect"/>
>>         <entry key="hibernate.jdbc.batch_size" value="10"/>
>>         <entry key="hibernate.jdbc.batch_versioned_data" value="true"/>
>>         <entry key="hibernate.jdbc.batch.builder"
>> value="com.software.persistence.OracleBatchBuilder"/>
>>         <entry key="hibernate.multiTenancy" value="DATABASE"/>
>>         <entry key="hibernate.tenant_identifier_resolver"
>>
>> value="com.software.persistence.MultitenantIdentifierResolver"/>
>>         <entry key="hibernate.multi_tenant_connection_provider"
>>                   value-ref="multiTenantConnectionProvider" />
>>     </map></property>
>>
>> Thanks,
>> Amit.
>> P.S - Since I am not getting any traction on this on the hibernate user
>> forum, I am re-posting this question on the dev forum.
>> _______________________________________________
>> hibernate-dev mailing list
>> hibernate-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>>
>
>


More information about the hibernate-dev mailing list