惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
J
Java Code Geeks
C
Check Point Blog
Last Week in AI
Last Week in AI
Microsoft Azure Blog
Microsoft Azure Blog
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
L
LangChain Blog
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 司徒正美
IT之家
IT之家
Martin Fowler
Martin Fowler
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
U
Unit 42
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ

博客园 - 消失的风

富文本编辑器vue2-editor实现全屏功能 使用Mist部署Contract到Rinkeby以太坊网络 基于以太坊的Token开发步骤 技术顾问认知(一) Angularjs-项目搭建 Augularjs-起步 appfuse:Excel导出 Appfuse:添加自定义页面组件 基于JQuery实现的文本框自动填充功能 Appfuse:权限控制 Appfuse:记录操作日志 Appfuse:扩展自己的GenericManager Appfuse:起步 JAVA实现图片裁剪 Mybatis基于注解的方式访问数据库 敏捷开发与jira之研发管理模式 敏捷开发与jira之阶段工作项概述 敏捷开发与jira之燃烧图 敏捷开发与jira之流程
Appfuse:第一张表维护
消失的风 · 2015-07-09 · via 博客园 - 消失的风

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. 重新部署即可