Created
July 23, 2018 07:55
-
-
Save anas-didi95/8f2b69134284f5c36bb572d93e0879ef to your computer and use it in GitHub Desktop.
hibernate_entity-models
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models; | |
import java.time.LocalDateTime; | |
import javax.persistence.Column; | |
import javax.persistence.Entity; | |
import javax.persistence.GeneratedValue; | |
import javax.persistence.Id; | |
import javax.persistence.JoinColumn; | |
import javax.persistence.ManyToOne; | |
import javax.persistence.Table; | |
import org.hibernate.annotations.CreationTimestamp; | |
import org.hibernate.annotations.UpdateTimestamp; | |
@Entity | |
@Table(name = "STRUTS2MAVEN_REG_LOGHISTORY") | |
public class LogHistory { | |
@Id | |
@GeneratedValue | |
@Column(name="ID", nullable=false) | |
private Long id; | |
@Column(name="MESSAGE", nullable=false) | |
private String message; | |
@Column(name="CREATE_DATETIME") | |
@CreationTimestamp | |
private LocalDateTime createDateTime; | |
@Column(name="UPDATE_DATETIME") | |
@UpdateTimestamp | |
private LocalDateTime updateDateTime; | |
@ManyToOne | |
@JoinColumn(name="USER_ID") | |
private User user; | |
public LogHistory() {} | |
public Long getId() { | |
return id; | |
} | |
public void setId(Long id) { | |
this.id = id; | |
} | |
public String getMessage() { | |
return message; | |
} | |
public void setMessage(String message) { | |
this.message = message; | |
} | |
public LocalDateTime getCreateDateTime() { | |
return createDateTime; | |
} | |
public void setCreateDateTime(LocalDateTime createDateTime) { | |
this.createDateTime = createDateTime; | |
} | |
public LocalDateTime getUpdateDateTime() { | |
return updateDateTime; | |
} | |
public void setUpdateDateTime(LocalDateTime updateDateTime) { | |
this.updateDateTime = updateDateTime; | |
} | |
public User getUser() { | |
return user; | |
} | |
public void setUser(User user) { | |
this.user = user; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models; | |
import java.time.LocalDateTime; | |
import java.util.Set; | |
import javax.persistence.Column; | |
import javax.persistence.Entity; | |
import javax.persistence.FetchType; | |
import javax.persistence.GeneratedValue; | |
import javax.persistence.Id; | |
import javax.persistence.OneToMany; | |
import javax.persistence.OrderBy; | |
import javax.persistence.Table; | |
import org.hibernate.annotations.CreationTimestamp; | |
import org.hibernate.annotations.UpdateTimestamp; | |
@Entity | |
@Table(name = "STRUTS2MAVEN_REG_USER") | |
public class User { | |
@Id | |
@GeneratedValue | |
@Column(name="ID") | |
private Long id; | |
@Column(name="FULLNAME", nullable=false) | |
private String fullname; | |
@Column(name="USERNAME", nullable=false) | |
private String username; | |
@Column(name="PASSWORD", nullable=false) | |
private String password; | |
@Column(name="EMAIL", nullable=false) | |
private String email; | |
@Column(name="CREATE_DATETIME") | |
@CreationTimestamp | |
private LocalDateTime createDateTime; | |
@Column(name="UPDATE_DATETIME") | |
@UpdateTimestamp | |
private LocalDateTime updateDateTime; | |
@OneToMany(fetch=FetchType.LAZY, mappedBy="user") | |
@OrderBy("createDateTime DESC") | |
private Set<LogHistory> logHistorySet; | |
public User () {} | |
public Long getId() { | |
return id; | |
} | |
public void setId(Long id) { | |
this.id = id; | |
} | |
public String getFullname() { | |
return fullname; | |
} | |
public void setFullname(String fullname) { | |
this.fullname = fullname; | |
} | |
public String getUsername() { | |
return username; | |
} | |
public void setUsername(String username) { | |
this.username = username; | |
} | |
public String getPassword() { | |
return password; | |
} | |
public void setPassword(String password) { | |
this.password = password; | |
} | |
public String getEmail() { | |
return email; | |
} | |
public void setEmail(String email) { | |
this.email = email; | |
} | |
public LocalDateTime getCreateDateTime() { | |
return createDateTime; | |
} | |
public void setCreateDateTime(LocalDateTime createDateTime) { | |
this.createDateTime = createDateTime; | |
} | |
public LocalDateTime getUpdateDateTime() { | |
return updateDateTime; | |
} | |
public void setUpdateDateTime(LocalDateTime updateDateTime) { | |
this.updateDateTime = updateDateTime; | |
} | |
public Set<LogHistory> getLogHistorySet() { | |
return logHistorySet; | |
} | |
public void setLogHistorySet(Set<LogHistory> logHistorySet) { | |
this.logHistorySet = logHistorySet; | |
} | |
@Override | |
public String toString() { | |
return "User [id=" + id + ", fullname=" + fullname + ", username=" + username + ", password=" + password | |
+ ", email=" + email + ", createDateTime=" + createDateTime + ", updateDateTime=" + updateDateTime | |
+ ", logHistorySet=" + logHistorySet + "]"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment