我有一个客户端和服务器设置与JBoss AS 7.1.1一起运行,我对我的persistence.xml有疑问。目前它看起来像这样:
<persistence>
<persistence-unit name="GrahamsProj">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/WorkCenterDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
</properties>
</persistence-unit>
</persistence>
我的服务器的META-INF文件夹中有persistence.xml。我必须遗漏一些属性,因为当我尝试查询我连接的数据库时,我收到此错误。
11:35:07,840 ERROR [org.jboss.ejb3.invocation] (EJB default - 1) JBAS014134:
EJB Invocation failed on component GrahamsProjBean for method public abstract
void grahamsprojserver.session.interfaces.GrahamsProjBeanRemote.test(): javax.ejb.EJB
Exception: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException:
Schemas is not mapped [FROM Schemas s]
我有什么遗失的吗?
答案 0 :(得分:6)
您需要在persistence.xml中包含所有模型类。例如:
<persistence>
<persistence-unit name="GrahamsProj">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/WorkCenterDS</jta-data-source>
<class>your.class.model.Example</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
</properties>
</persistence-unit>
</persistence>
答案 1 :(得分:1)
您可能还需要更新hibernate.dialect属性。在您的示例中,您正在使用&#34; org.hibernate.dialect.HSQLDialect&#34;并且您使用Oracle驱动程序,例如&#34; oracle.jdbc.OracleDriver&#34 ;.如果您使用的是Oracle数据库,则需要更新hibernate方言,例如: &#34; org.hibernate.dialect.Oracle10gDialect&#34;
这是您的更新代码:
<persistence>
<persistence-unit name="GrahamsProj">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/WorkCenterDS</jta-data-source>
<class>your.class.model.Example</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
</properties>
</persistence-unit>
</persistence>