Here's our class Entity
@MappedSuperclass public abstract class Entity implements Identifiable<String>, Serializable { public static final String PROPERTY_NAME_ID = "id";
@Id @GeneratedValue(generator = "uuid2") @GenericGenerator(name = "uuid2", strategy = "uuid2") @Column(columnDefinition = "varchar", unique = true, nullable = false) private String id;
@Override public String getId() { return id; }
@Override public void setId(final String id) { this.id = id; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); return result; }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; }
if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; }
final Entity other = (Entity) obj;
if (id == null) { if (other.id != null) { return false; }
} else if (!id.equals(other.id)) { return false; }
return true; } }
and here Description Entity
@MappedSuperclass public abstract class DescriptionEntity extends Entity { @Column(name = "description_lang1", nullable = false, length = 100) private String descriptionLang1;
@Column(name = "description_lang2", length = 100) private String descriptionLang2;
@Column(name = "description_lang3", length = 100) private String descriptionLang3;
public String getDescriptionLang1() { return this.descriptionLang1; }
public void setDescriptionLang1(final String descriptionLang1) { this.descriptionLang1 = descriptionLang1; }
public String getDescriptionLang2() { return this.descriptionLang2; }
public void setDescriptionLang2(final String descriptionLang2) { this.descriptionLang2 = descriptionLang2; }
public String getDescriptionLang3() { return this.descriptionLang3; }
public void setDescriptionLang3(final String descriptionLang3) { this.descriptionLang3 = descriptionLang3; }
}
now you have the whole hierarchy
|