@NaturalId(mutable = true) public String getName() { return name; }
@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 @GeneratedValue private Long id; @NaturalId private String registrationNumber; @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) private List<Address> addresses = new ArrayList<>(); public Person() { } public Person(String registrationNumber) { this.registrationNumber = registrationNumber; } public void addAddress(Address address) { addresses.add( address ); address.owners.add( this ); } }
@Basic @NaturalId public String getCode() { return code; }
/** * @author Donnchadh O Donnabhain */ @Entity public class A { @EmbeddedId private AId accountId; @NaturalId(mutable = false) private String shortCode; protected A() { } public A(AId accountId, String shortCode) { this.accountId = accountId; this.shortCode = shortCode; } public String getShortCode() { return shortCode; } public AId getAccountId() { return accountId; } }
@Entity( name = "Person" ) @Table( name = "persons" ) @Cacheable @Cache( region = "a.b.c", usage = CacheConcurrencyStrategy.READ_WRITE ) @NaturalIdCache( region = "a.b.c" ) public static class Person { @Id public Integer id; @NaturalId public String name; @ElementCollection @Cache( region = "a.b.c", usage = CacheConcurrencyStrategy.READ_WRITE ) public List<String> nickNames; }