2013-03-16 77 views
0

我使用Struts /泉/休眠和Tomcat 7.0,并试图启动服务器时,我发现了一个问题,Hibernate的映射。休眠:无法应用约束的DDL

控制台会打印:

Mapping class: path.vo.ObjectVO -> TABLE_NAME 

在休眠文件夹中找到在HibernateSessionFactory.xml文件及其关联VO对象中的每个项目。它将成功遍历整个列表。

然而,一旦这似乎是成功的,它闷死了一对夫妇的对象,给这个错误:

WARN: Unable to apply constraints on DDL for path.vo.ObjectVO 
java.lang.ClassNotFoundException: path.vo.ObjectVO 

奇怪的是,所使用的服务器来运行良好。自从它成功运行以来,我没有更改任何hibernate配置文件,VO对象或数据库模式本身。我的研究仅导致人们用他们的配置文件解决了问题,这些问题对我来说并不奏效。

任何帮助,将不胜感激。以下是我正在使用的一些文件。

HibernateSessionFactory.xml

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> 

<!-- Hibernate session factory --> 
<bean id="sessionFactory"  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 

    <property name="dataSource"> 
     <ref bean="dataSource"/> 
    </property> 

    <property name="hibernateProperties"> 
     <props> 
      <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop> 
      <prop key="hibernate.show_sql">true</prop> 
     </props> 
    </property> 

    <property name="mappingResources"> 
     <list> 
      <value>hibernate/ClassA.hbm.xml</value> 
      <value>hibernate/ClassB.hbm.xml</value> 
     </list> 
    </property> 
</bean> 

ClassA.hbm.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> 
<hibernate-mapping> 
<class name="path.to.ClassAVO" table="CLASSA"> 
    <id name ="Id" type="int"> 
     <column name="ID"/> 
     <generator class="identity" /> 
    </id> 
    <property name="somecolumn" type="string"> 
     <column name="Somecolumn" length="24" not-null="true" /> 
    </property> 
... 
</class> 
</hibernate-mapping> 
+0

你映射ObjectVO于某些表? VO不应该是持久的 – 2013-03-18 05:31:15

+0

@HenryLeu我认为这行代码如下: user1287523 2013-03-19 03:25:22

回答

0
  1. 两个采购订单马平到同一个表禁止在休眠。
  2. VO应该是封装数据并跨层转移而不是持久化。
  3. 我建议你最好遵循开放式surce社区熟悉的分层设计的良好做法,可以帮助你。

Working with objects in hibernate