我有一个带有 spring 3.1.0、hibernate 4.0 和 jboss 7.1.1 的应用程序
Aim -动态扩展属性以加载持久性单元。
<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>
持久性.xml
<persistence-unit name="cassandra">
<properties>
<property name="jboss.as.jpa.managed" value="false"/>
</properties>
</persistence-unit>
现在有了“jboss.as.jpa.managed”,我正在停止 jboss 的休眠以自动加载 cassandra 单元。我能够通过我的 bean 的上述定义成功加载属性。但是在运行时我的实体“UsageItem”正在生成以下异常
org.hibernate.hql.internal.ast.QuerySyntaxException:UsageItem 未映射
但奇怪的是,如果我手动硬编码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>
当我像上面的persistence.xml一样进行硬编码时,我说的是休眠以加载Persistence-unit,他运行得很好。我认为 spring 无法加载我的实体“UsageItem”的元数据。我不知道 spring 缺少什么,他不允许我继续前进。现在一个星期,但仍然卡住。