簡體   English   中英

Eclipse 中的休眠 - 逆向工程

[英]Hibernate in Eclipse - Reverse engineering

我正在嘗試在 Eclipse IDE 中使用 hibernate,我已經成功地逆向工程了 POJO 類。 但是它在會話工廠下的休眠配置中顯示錯誤。

在此處輸入圖片說明

休眠文件.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.reven.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;
}

}

客戶.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>

像這樣更新 customer.hbm.xml 中的映射條目 -

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM