@NaturalId(mutable = true) public String getName() { return name; }
throw new AnnotationException( "@NaturalId only valid on root entity (or its @MappedSuperclasses)" ); if ( ! naturalId.mutable() ) { updatable = false;
null; if ( naturalId != null ) { if ( !naturalId.mutable() ) { updatable = false;
@NaturalId public String getUserName() { return userName; }
@NaturalId @Column(name = "natural_id") public String getUid() { return uid; }
@Entity(name = "Employee") public static class Employee { @Id private Long id; @NaturalId private String username; private String password; }
@Entity(name = "PropertyEntity") public static class Property implements Serializable { @Id private Integer id; @NaturalId private Integer code; @NaturalId private Integer item; private String description = "A description ..."; protected Property(){} public Property(Integer id, Integer code, Integer item) { this.id = id; this.code = code; this.item = item; } } }
@Entity(name = "Employee") public static class Employee { @Id private Long id; @NaturalId private String username; @ManyToOne(fetch = FetchType.EAGER) private Department department; //Getters and setters omitted for brevity } //end::fetching-direct-vs-query-domain-model-example[]
@Entity(name = "Employee") public static class Employee { @Id private Long id; @NaturalId private String username; @Column(name = "next_vacation", columnDefinition = "INTEGER") private YearMonth nextVacation; }
@Entity(name = "Employee") public static class Employee { @Id @GeneratedValue private Long id; @NaturalId private String username; @ManyToOne(fetch = FetchType.LAZY) private Department department; //Getters and setters omitted for brevity } //end::fetching-strategies-fetch-mode-select-mapping-example[]
@Entity(name = "Employee") public static class Employee { @Id @GeneratedValue private Long id; @NaturalId private String username; @ManyToOne(fetch = FetchType.LAZY) private Department department; //Getters and setters omitted for brevity } }
@Entity(name = "Employee") public static class Employee { @Id @GeneratedValue private Long id; @NaturalId private String username; @ManyToOne(fetch = FetchType.LAZY) private Department department; //Getters and setters omitted for brevity } }
/** * @author Andrea Boriero */ @Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public abstract class Element { @Id @GeneratedValue private Long id; @Column(unique = true) @NaturalId private String code; }
@Entity public class ClassWithIdentityColumn { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @NaturalId(mutable = true) private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }
@Entity(name = "Person") public static class Person { @Id @GeneratedValue private Long id; @NaturalId private String registrationNumber; public Person() { } public Person(String registrationNumber) { this.registrationNumber = registrationNumber; } public Long getId() { return id; } public String getRegistrationNumber() { return registrationNumber; } }
@Basic @NaturalId public String getReferenceCode() { return referenceCode; }
@Override @NaturalId public String getName() { return super.getName(); } }
@Entity(name = "Person") public static class Person { @Id @GeneratedValue private Long id; @NaturalId private String registrationNumber; public Person() { } public Person(String registrationNumber) { this.registrationNumber = registrationNumber; } public Long getId() { return id; } public String getRegistrationNumber() { return registrationNumber; } }
@Entity(name = "Person") public static class Person { @Id private Long id; @NaturalId private String registrationNumber; public Person() {} public Person(String registrationNumber) { this.registrationNumber = registrationNumber; } //Getters and setters are omitted for brevity //end::identifiers-derived-primarykeyjoincolumn[] public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getRegistrationNumber() { return registrationNumber; } //tag::identifiers-derived-primarykeyjoincolumn[] }
@Entity(name = "Person") public static class Person { @Id private Long id; @NaturalId private String registrationNumber; public Person() {} public Person(String registrationNumber) { this.registrationNumber = registrationNumber; } //Getters and setters are omitted for brevity //end::identifiers-derived-mapsid[] public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getRegistrationNumber() { return registrationNumber; } //tag::identifiers-derived-mapsid[] }