Appfuse: First Table Maintenance

Source: Internet
Author: User

1. Create a table UserInfo

Column Name Describe
Userid Primary key, self-increment
UserName User name
Pwd Password
CreateDate Date Created

2. Add files to the Src/main/resources directory Hibernate.reveng.xml

<?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-typeJdbc-type= "VARCHAR"length= ' 1 'Hibernate-type= "Yes_no"/>        <!--length, scale and precision can is used to specify the mapping precisly -        <Sql-typeJdbc-type= "NUMERIC"Precision= ' 1 'Hibernate-type= "Boolean"/>        <!--The type-mappings is ordered. This mapping would be consulted last, thus overriden by the previous one if Precision=1 for the column -        <Sql-typeJdbc-type= "BIGINT"Hibernate-type= "Java.lang.Long"/>        <Sql-typeJdbc-type= "INTEGER"Hibernate-type= "Java.lang.Long"/>        <Sql-typeJdbc-type= "NUMERIC"Hibernate-type= "Java.lang.Long"/>    </type-mapping>    <Table-filterMatch-name="*"Exclude= "true"/>    <Table-filterMatch-name= "UserInfo"Exclude= "false"/></hibernate-reverse-engineering>
Hibernate.reveng.xml

3. Open the command line and enter MVN Appfuse:gen-model to generate the entity class Userinfo.java

 PackageCom.zcmp.disappearwind.model;ImportCom.zcmp.disappearwind.model.BaseObject;Importorg.hibernate.search.annotations.DocumentId;ImportOrg.hibernate.search.annotations.Field;Importorg.hibernate.search.annotations.Indexed;Importorg.hibernate.search.annotations.IndexedEmbedded;Importjava.util.Date;ImportJavax.persistence.Column;Importjavax.persistence.Entity;ImportJavax.persistence.GeneratedValue;Import StaticJavax.persistence.GenerationType.IDENTITY;Importjavax.persistence.Id;Importjavax.persistence.Table;Importjavax.persistence.Temporal;ImportJavax.persistence.TemporalType;ImportJavax.persistence.GeneratedValue;ImportJavax.persistence.GenerationType;Importjavax.xml.bind.annotation.XmlRootElement;Importjava.io.Serializable; @Entity @table (name= "Userinfot", catalog= "Disappearwind") @Indexed @xmlrootelement Public classUserinfoextendsBaseobjectImplementsSerializable {PrivateLong userId; PrivateDate CreateDate; PrivateString pwd; PrivateString UserName; @Id @GeneratedValue (Strategy=IDENTITY) @DocumentId PublicLong getUserId () {return  This. userId; }         Public voidSetuserid (Long userId) { This. UserId =userId; } @Temporal (Temporaltype.timestamp) @Column (name= "CreateDate", length=19) @Field PublicDate getcreatedate () {return  This. CreateDate; }         Public voidsetcreatedate (Date createdate) { This. CreateDate =CreateDate; } @Column (Name= "PWD", length=128) @Field PublicString getpwd () {return  This. pwd; }         Public voidsetpwd (String pwd) { This. PWD =pwd; } @Column (Name= "UserName", length=128) @Field PublicString GetUserName () {return  This. UserName; }         Public voidsetusername (String userName) { This. UserName =UserName; }     Public Booleanequals (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 inthashcode () {intresult = 0; Result= (CreateDate! =NULL? Createdate.hashcode (): 0); Result= * result + (pwd! =NULL? Pwd.hashcode (): 0); Result= to * result + (userName! =NULL? Username.hashcode (): 0); returnresult; }     PublicString toString () {StringBuffer sb=NewStringBuffer (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 ("]"); returnsb.tostring (); }}
Userinfo

4. Run MVN appfuse:gen on the command number to generate pages, controllers, menu configuration and other files, note that when prompted to enter the entity name, the case must be consistent with the class name generated in the third step

5. Open the Applicationresources_zh.properties file, the name of each field and various headings and tips

6. Re-deploy

Appfuse: First Table Maintenance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.