2016-07-20 38 views
0

我想在eclipse IDE中使用hibernate,我已经成功地逆向工程POJO类。但是它在会话工厂的hibernate配置中显示错误。Eclipse中的休眠 - 逆向工程

enter image description here

的hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE hibernate-configuration PUBLIC 
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> 
<hibernate-configuration> 
<session-factory> 
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
    <property name="hibernate.connection.password">1234</property> 
    <property name="hibernate.connection.url">jdbc:mysql://localhost/customer</property> 
    <property name="hibernate.connection.username">root</property> 
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> 


    <mapping class="com.example.pojo.Customer"/> 
    <mapping resource="com/example/pojo/Customer.hbm.xml"/> 
</session-factory> 
</hibernate-configuration> 

hibernate.reveng.xml中

<?xml version="1.0" encoding="UTF-8"?> 

<hibernate-reverse-engineering> 
<table-filter match-catalog="customer" match-name="customer" /> 
<table catalog="customer" name="customer"> 
    <column name="id"></column> 
    <column name="firstName"></column> 
    <column name="cuscol"></column> 
    <column name="lastName"></column> 
    <column name="birthDate"></column> 
    <column name="email"></column> 
</table> 
</hibernate-reverse-engineering> 

客户POJO的

public class Customer implements java.io.Serializable { 

private int id; 
private String firstName; 
private String cuscol; 
private String lastName; 
private Date birthDate; 
private String email; 

public Customer() { 
} 

public Customer(int id) { 
    this.id = id; 
} 

public Customer(int id, String firstName, String cuscol, String lastName, Date birthDate, String email) { 
    this.id = id; 
    this.firstName = firstName; 
    this.cuscol = cuscol; 
    this.lastName = lastName; 
    this.birthDate = birthDate; 
    this.email = email; 
} 

public int getId() { 
    return this.id; 
} 

public void setId(int id) { 
    this.id = id; 
} 

public String getFirstName() { 
    return this.firstName; 
} 

public void setFirstName(String firstName) { 
    this.firstName = firstName; 
} 

public String getCuscol() { 
    return this.cuscol; 
} 

public void setCuscol(String cuscol) { 
    this.cuscol = cuscol; 
} 

public String getLastName() { 
    return this.lastName; 
} 

public void setLastName(String lastName) { 
    this.lastName = lastName; 
} 

public Date getBirthDate() { 
    return this.birthDate; 
} 

public void setBirthDate(Date birthDate) { 
    this.birthDate = birthDate; 
} 

public String getEmail() { 
    return this.email; 
} 

public void setEmail(String email) { 
    this.email = email; 
} 

} 

customer.hbm.xml

<?xml version="1.0"?> 
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> 
<!-- Generated Jul 20, 2016 4:45:13 PM by Hibernate Tools 4.0.0 --> 
<hibernate-mapping> 
<class name="Customer" table="customer" catalog="customer"> 
    <id name="id" type="int"> 
     <column name="id" /> 
     <generator class="assigned" /> 
    </id> 
    <property name="firstName" type="string"> 
     <column name="firstName" length="45" /> 
    </property> 
    <property name="cuscol" type="string"> 
     <column name="cuscol" length="45" /> 
    </property> 
    <property name="lastName" type="string"> 
     <column name="lastName" length="45" /> 
    </property> 
    <property name="birthDate" type="date"> 
     <column name="birthDate" length="10" /> 
    </property> 
    <property name="email" type="string"> 
     <column name="email" length="45" /> 
    </property> 
</class> 
</hibernate-mapping> 
+0

哎呀这是there..sory – user2486322

+0

执行制图和资源映射类两个人都需要出席相同的Pojo?它可能不会引发错误..但看起来不合适 –

回答

0

在customer.hbm.xml更新映射条目这样的 -

<class="com.example.pojo.Customer" table= "customer"/> 
+0

属性“表”无效 – user2486322