1 package de.spring.example.persistence.domain;
3 import java.io.Serializable;
5 import javax.persistence.CascadeType;
6 import javax.persistence.Column;
7 import javax.persistence.Entity;
8 import javax.persistence.FetchType;
9 import javax.persistence.GeneratedValue;
10 import javax.persistence.GenerationType;
11 import javax.persistence.Id;
12 import javax.persistence.JoinColumn;
13 import javax.persistence.ManyToOne;
14 import javax.persistence.Table;
15 import javax.validation.constraints.Max;
16 import javax.validation.constraints.NotNull;
17 import javax.validation.constraints.Size;
19 import org.hibernate.envers.Audited;
21 import com.fasterxml.jackson.annotation.JsonIdentityInfo;
22 import com.fasterxml.jackson.annotation.ObjectIdGenerators;
26 @Table(name="AD_DESCRIPTION", schema="mybatis_example")
27 @JsonIdentityInfo(generator=ObjectIdGenerators.IntSequenceGenerator.class, property="jsonId")
28 public class AdDescription implements Serializable {
31 @GeneratedValue(strategy=GenerationType.IDENTITY)
32 @Column(name="ID", updatable=false, nullable=false)
35 @ManyToOne(fetch=FetchType.LAZY, cascade = CascadeType.ALL, optional=true)
36 @JoinColumn(name="AD_ID", nullable=false, updatable = false, insertable = false, referencedColumnName="ID")
41 @Column(name="LANGUAGE_ID")
42 private Long languageId;
46 @Column(name="AD_NAME")
47 private String adName;
51 @Column(name="AD_DESCRIPTION")
52 private String adDescription;
56 @Column(name="AD_MOBILE_TEXT")
57 private String adMobileText;
60 @Size(min=2, max=3000)
61 @Column(name="AD_LINK")
62 private String adLink;
64 // It will be used by JPA when filling the property fields with data coming from data base.
65 protected AdDescription() {
69 // It will be used by my code (for example by Unit Tests)
70 public AdDescription(Long id, Ad ad, Long languageId, String adName, String adDescription,
71 String adMobileText, String adLink) {
74 this.languageId = languageId;
76 this.adDescription = adDescription;
77 this.adMobileText = adMobileText;
82 * WARNING: JPA REQUIRES GETTERS!!!
93 public Long getLanguageId() {
97 public String getAdName() {
101 public String getAdDescription() {
102 return adDescription;
105 public String getAdMobileText() {
109 public String getAdLink() {