0

I have a application with spring 3.1.0, hibernate 4.0 and jboss 7.1.1

Aim - Dynamic expansion of properties to load persistence unit .

<bean id="propertyPlaceholder"  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="searchSystemEnvironment" value="true" />
    <property name="locations">
        <list>
                <value> file:/${PROPERTY_HOME}/jpa/kundera_jpa.properties</value>  
        </list>
    </property>
</bean>

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" > 
    <property name="persistenceXmlLocation" value="classpath:./META-INF/persistence.xml"/> 
    <property name="persistenceUnitName" value="cassandra"/>
    <property  name="persistenceProvider" >
         <bean class="com.impetus.kundera.KunderaPersistence" />
    </property> 
    <property name="jpaProperties">
        <props>
        <prop key="kundera.nodes">${cassandra.kundera.nodes}</prop>
        <prop key="kundera.port">${cassandra.kundera.port}</prop>
        <prop key="kundera.keyspace">${cassandra.kundera.keyspace}</prop>
        <prop key="kundera.dialect">${cassandra.kundera.dialect}</prop>
        <prop key="kundera.client.lookup.class">${cassandra.kundera.client.lookup.class}</prop>
        <prop key="jboss.as.jpa.providerModule">com.impetus.kundera</prop>
        </props>
    </property>
</bean>

persistence.xml

<persistence-unit name="cassandra">
        <properties> 
             <property name="jboss.as.jpa.managed" value="false"/> 
        </properties>   
</persistence-unit>

Now with 'jboss.as.jpa.managed' , i am stopping hibernate of jboss to load the cassandra unit automatically . I am able to successfully load the properties via above definaion of my bean . But while runtime my entity 'UsageItem' is generating the following exception

org.hibernate.hql.internal.ast.QuerySyntaxException: UsageItem is not mapped

But strangely the same code is working if i manually hard code the properties in persistence.xml -

<persistence-unit name="cassandra">
    <provider>com.impetus.kundera.KunderaPersistence</provider>
     <properties>
        <property name="kundera.nodes" value="172.16.9.70" />
        <property name="kundera.port" value="9160" /> 
        <property name="kundera.keyspace" value="iaas" />
        <property name="kundera.dialect" value="cassandra" />
        <property name="kundera.client.lookup.class" value="com.example.client.cassandra.pelops.JCPelopsClientFactory" />
        <property name="jboss.as.jpa.providerModule" value="com.impetus.kundera"/>          
    </properties>
</persistence-unit>

While when i am hardcoding as in above persistence.xml, i am saying hibernate to load the Persistence-unit , which he is operating perfectly fine . I think spring is not able to load the metadata of my entity 'UsageItem' .I dont know what i am missing with spring that he is not allowing me to move forward . One week now but still stuck .

ip_x
  • 172
  • 2
  • 6

1 Answers1

0

Looks like you are trying to use Kundera as persistence provider with JBoss?

I would suggest to try recent 2.6 release with "jboss.as.jpa.managed" to false. Creating a jboss module will not help much and it require to package some libraries and bundle with modules.

Also,If UsageItem is annotated correctly with @Table annotation as required by Kundera, it should work.

-Vivek

vivek mishra
  • 1,162
  • 8
  • 16
  • UsageItem is annotated correctly with @Table , because as i mentioned earlier ' same code is working if i manually hard code the properties in persistence.xml ' .But i am yet to try the new kundera 2.6 release . – ip_x Jul 26 '13 at 05:38