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="laguage_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() {