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.
Show replies by date