Java tutorial
/** * Copyright © 2012-2013 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); */ package com.yuga.ygplatform.modules.sys.entity; import java.util.Date; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import com.yuga.ygplatform.common.persistence.BaseEntity; /** * Entity * @author ThinkGem * @version 2013-05-30 */ @Entity @Table(name = "sys_log") @DynamicInsert @DynamicUpdate @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class Log extends BaseEntity { private static final long serialVersionUID = 1L; private Long id; // ? private String type; // 12 private User createBy; // private Date createDate; // private String remoteAddr; // ?IP? private String requestUri; // ?URI private String method; // ?? private String params; // ???? private String userAgent; // ??? private String exception; // ? public static final String TYPE_ACCESS = "1"; public static final String TYPE_EXCEPTION = "2"; public Log() { super(); } public Log(Long id) { this(); this.id = id; } @Id @GeneratedValue(strategy = GenerationType.AUTO) // @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_sys_log") // @SequenceGenerator(name = "seq_sys_log", sequenceName = "seq_sys_log") public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getType() { return type; } public void setType(String type) { this.type = type; } @JsonIgnore @ManyToOne(fetch = FetchType.LAZY) @NotFound(action = NotFoundAction.IGNORE) public User getCreateBy() { return createBy; } public void setCreateBy(User createBy) { this.createBy = createBy; } @Temporal(TemporalType.TIMESTAMP) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") public Date getCreateDate() { return createDate; } public void setCreateDate(Date createDate) { this.createDate = createDate; } public String getRemoteAddr() { return remoteAddr; } public void setRemoteAddr(String remoteAddr) { this.remoteAddr = remoteAddr; } public String getUserAgent() { return userAgent; } public void setUserAgent(String userAgent) { this.userAgent = userAgent; } public String getRequestUri() { return requestUri; } public void setRequestUri(String requestUri) { this.requestUri = requestUri; } public String getMethod() { return method; } public void setMethod(String method) { this.method = method; } public String getParams() { return params; } public void setParams(String params) { this.params = params; } public String getException() { return exception; } public void setException(String exception) { this.exception = exception; } }