Appfuse:第一张表维护

1. 建立表userinfo

列名 描述
UserID  主键、自增
UserName 用户名
Pwd 密码
CreateDate 创建日期

2. 在src/main/resources目录下增加文件hibernate.reveng.xml,并在pom.xml中配置build子标签

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering
  SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>

    <type-mapping>
        <!-- jdbc-type is name fom java.sql.Types -->
        <sql-type jdbc-type="VARCHAR" length='1' hibernate-type="yes_no"/>
        <!-- length, scale and precision can be used to specify the mapping precisly -->
        <sql-type jdbc-type="NUMERIC" precision='1' hibernate-type="boolean"/>
        <!-- the type-mappings are ordered. This mapping will be consulted last,
        thus overriden by the previous one if precision=1 for the column -->
        <sql-type jdbc-type="BIGINT" hibernate-type="java.lang.Long"/>
        <sql-type jdbc-type="INTEGER" hibernate-type="java.lang.Long"/>
        <sql-type jdbc-type="NUMERIC" hibernate-type="java.lang.Long"/>
    </type-mapping>

    <table-filter match-name="*" exclude="true"/>
    <table-filter match-name="userinfo" exclude="false"/>
</hibernate-reverse-engineering>
hibernate.reveng.xml
 1 <plugin>
 2                 <groupId>org.appfuse.plugins</groupId>
 3                 <artifactId>appfuse-maven-plugin</artifactId>
 4                 <version>${project.parent.version}</version>
 5                 <configuration>
 6                     <componentProperties>
 7                         <revengfile>src/main/resources/hibernate.reveng.xml</revengfile>
 8                     </componentProperties>
 9                     <genericCore>${amp.genericCore}</genericCore>
10                     <fullSource>${amp.fullSource}</fullSource>
11                 </configuration>
12                 <dependencies>
13                     <dependency>
14                         <groupId>${jdbc.groupId}</groupId>
15                         <artifactId>${jdbc.artifactId}</artifactId>
16                         <version>${jdbc.version}</version>
17                     </dependency>
18                 </dependencies>
19             </plugin>
pom的配置

 

3. 打开命令行,输入mvn appfuse:gen-model 生成实体类userinfo.java 

package com.zcmp.disappearwind.model;

import com.zcmp.disappearwind.model.BaseObject;

import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

import javax.xml.bind.annotation.XmlRootElement;

import java.io.Serializable;

@Entity
@Table(name="userinfot",catalog="disappearwind")
@Indexed
@XmlRootElement
public class Userinfo extends BaseObject implements Serializable {
    private Long userId;
    private Date createDate;
    private String pwd;
    private String userName;

    @Id @GeneratedValue(strategy=IDENTITY) @DocumentId    
    public Long getUserId() {
        return this.userId;
    }
    
    public void setUserId(Long userId) {
        this.userId = userId;
    }
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="CreateDate", length=19)
    @Field
    public Date getCreateDate() {
        return this.createDate;
    }
    
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }
    
    @Column(name="Pwd", length=128)
    @Field
    public String getPwd() {
        return this.pwd;
    }
    
    public void setPwd(String pwd) {
        this.pwd = pwd;
    }
    
    @Column(name="UserName", length=128)
    @Field
    public String getUserName() {
        return this.userName;
    }
    
    public void setUserName(String userName) {
        this.userName = userName;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Userinfo pojo = (Userinfo) o;

        if (createDate != null ? !createDate.equals(pojo.createDate) : pojo.createDate != null) return false;
        if (pwd != null ? !pwd.equals(pojo.pwd) : pojo.pwd != null) return false;
        if (userName != null ? !userName.equals(pojo.userName) : pojo.userName != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (createDate != null ? createDate.hashCode() : 0);
        result = 31 * result + (pwd != null ? pwd.hashCode() : 0);
        result = 31 * result + (userName != null ? userName.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("userId").append("='").append(getUserId()).append("', ");
        sb.append("createDate").append("='").append(getCreateDate()).append("', ");
        sb.append("pwd").append("='").append(getPwd()).append("', ");
        sb.append("userName").append("='").append(getUserName()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
Userinfo

4. 在命令号运行mvn appfuse:gen生成页面、Controller、menu配置等文件,注意提示输入实体名的时候大小写一定要和第三步生成的类名保持一致

5. 打开ApplicationResources_zh.properties文件,汉化各字段的名称以及各种标题和提示信息

6. 重新部署即可

 

posted @ 2015-07-09 16:44  消失的风  阅读(416)  评论(0编辑  收藏  举报