【1】库表
【2】类 注意字段的注解
1 package com.jspxcms.core.domain; 2 3 import java.io.Serializable; 4 import java.util.Date; 5 6 import javax.persistence.Column; 7 import javax.persistence.Entity; 8 import javax.persistence.GeneratedValue; 9 import javax.persistence.GenerationType; 10 import javax.persistence.Id; 11 import javax.persistence.JoinColumn; 12 import javax.persistence.Lob; 13 import javax.persistence.NamedQuery; 14 import javax.persistence.OneToOne; 15 import javax.persistence.Table; 16 import javax.persistence.TableGenerator; 17 import javax.persistence.Temporal; 18 import javax.persistence.TemporalType; 19 20 /** 21 * 22 * 基本概况 23 * 24 */ 25 26 @Entity 27 @Table(name = "cms_baseinfo") 28 @NamedQuery(name = "CmsBaseinfo.findAll", query = "SELECT c FROM CmsBaseinfo c") 29 public class CmsBaseinfo implements Serializable { 30 private static final long serialVersionUID = 1L; 31 32 private Integer id; 33 private String basename; 34 private String photourl; 35 private User createUser; 36 private Date publishtime; 37 private String basedetails;// 详情 38 private int bstatus;//由于区分是否显示 1为显示 0为不显示 39 40 public CmsBaseinfo() { 41 super(); 42 } 43 44 @Id 45 @Column(name = "id", unique = true, nullable = false) 46 @TableGenerator(name = "tg_cms_baseinfo", pkColumnValue = "cms_baseinfo", table = "t_id_table", pkColumnName = "f_table", valueColumnName = "f_id_value", initialValue = 1, allocationSize = 1) 47 @GeneratedValue(strategy = GenerationType.TABLE, generator = "tg_cms_baseinfo") 48 public Integer getId() { 49 return id; 50 } 51 52 public void setId(Integer id) { 53 this.id = id; 54 } 55 56 @Column(name = "basename") 57 public String getBasename() { 58 return basename; 59 } 60 61 public void setBasename(String basename) { 62 this.basename = basename; 63 } 64 65 @Column(name = "photourl", nullable = true) // ——表示可以为null 66 public String getPhotourl() { 67 return photourl; 68 } 69 70 public void setPhotourl(String photourl) { 71 this.photourl = photourl; 72 } 73 74 @OneToOne 75 @JoinColumn(name = "create_user_id") 76 public User getCreateUser() { 77 return createUser; 78 } 79 80 public void setCreateUser(User createUser) { 81 this.createUser = createUser; 82 } 83 84 @Temporal(TemporalType.DATE) //有TemporalType.DATE TemporalType.TIME TemporalType.TIMESTAMP 85 @Column(name = "publishtime", nullable = true, length = 10) //10表示显示日期为2016-09-05 86 public Date getPublishtime() { 87 return publishtime; 88 } 89 90 public void setPublishtime(Date publishtime) { 91 this.publishtime = publishtime; 92 } 93 94 @Lob //大文本 95 public String getBasedetails() { 96 return basedetails; 97 } 98 99 public void setBasedetails(String basedetails) { 100 this.basedetails = basedetails; 101 } 102 103 @Column(name = "bstatus") 104 public int getBstatus() { 105 return bstatus; 106 } 107 108 public void setBstatus(int bstatus) { 109 this.bstatus = bstatus; 110 } 111 112 }
【3】dao service 略
【4】页面
【5】结果样式