@Id public String getInvoiceId() { return invoiceId; }
@LastModifiedDate private Date lastModified; @CreatedDate private Date createdAt;
/** * User domain class that uses auditing functionality of Spring Data that can either be aquired implementing * {@link Auditable} or extend {@link AbstractAuditable}. * * @author Oliver Gierke * @author Thomas Darimont */ @Data @Entity @EntityListeners(AuditingEntityListener.class) public class AuditableUser { private @Id @GeneratedValue Long id; private String username; private @CreatedDate LocalDateTime createdDate; private @LastModifiedDate LocalDateTime lastModifiedDate; private @ManyToOne @CreatedBy AuditableUser createdBy; private @ManyToOne @LastModifiedBy AuditableUser lastModifiedBy; }
/** * Creates a new {@link Order} for the given {@link Customer}, shipping and billing {@link Address}. * * @param customer must not be {@literal null}. * @param shippingAddress must not be {@literal null}. * @param billingAddress can be {@literal null}. */ @PersistenceConstructor public Order(Customer customer, Address shippingAddress, Address billingAddress) { Assert.notNull(customer); Assert.notNull(shippingAddress); this.customer = customer; this.shippingAddress = shippingAddress; this.billingAddress = billingAddress; }
public class Customer { @Id public String id; public String firstName; public String lastName; public Customer() {} public Customer(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } @Override public String toString() { return String.format( "Customer[id=%s, firstName='%s', lastName='%s']", id, firstName, lastName); } }
@LastModifiedDate private Date lastModified; @CreatedDate private Date createdAt;
/** * A line item. * * @author Thomas Darimont * @author Oliver Gierke */ @Data @RequiredArgsConstructor(onConstructor = @__(@PersistenceConstructor)) public class LineItem { private final String caption; private final double price; int quantity = 1; public LineItem(String caption, double price, int quantity) { this(caption, price); this.quantity = quantity; } }
/** * A {@link User}. * * @author Oliver Gierke */ @Value public class User { private final @Id UUID id = UUID.randomUUID(); private final String username; }
/** * @author Oliver Gierke */ @MappedSuperclass @EntityListeners(AuditingEntityListener.class) public abstract class AbstractEntity { @Id @GeneratedValue Long id; @CreatedDate LocalDateTime createdDate; @LastModifiedDate LocalDateTime modifiedDate; }
/** * A manual instructing how to assemble a {@link LegoSet}. * * @author Jens Schauder */ @Data public class Manual { private @Id Long id = null; private String author; private String text; Manual(String text, String author) { this.author = author; this.text = text; } }
/** * A Lego Set consisting of multiple Blocks and a manual * * @author Jens Schauder */ @Data public class LegoSet { private Map<String, Model> models = new HashMap<>(); private @Id Integer id; private String name; private Manual manual; public void addModel(String name, String description) { Model model = new Model(); model.name = name; model.description = description; models.put(name, model); } }
/** * An entity to represent a Person. * * @author Thomas Darimont */ @Data @RequiredArgsConstructor public class Person { private @Id String id; private final String firstname; private final String lastname; }
/** * @author Oliver Gierke */ @Data @AllArgsConstructor class Customer { @Id Integer id; String firstname, lastname; }
/** * An entity to represent a {@link Person}. * * @author Thomas Darimont */ @Data @RequiredArgsConstructor public class Person { private @Id String id; private final String firstname; private final String lastname; }
/** * @author Hartmut Lang */ @Data @NoArgsConstructor public class Customer { @Id private String id; private String firstName; private String lastName; public Customer(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } }
/** * @author Mark Paluch */ @Value @Table class Customer { @Id String id; String firstname, lastname; }
/** * @author Christoph Strobl */ @Data public class Planet { final @Id String name; final @GeoSpatialIndexed Point coordinates; }
/** * Sample Addressbook class. * * @author Mark Paluch */ @Data @Table public class Addressbook { @Id String id; Contact me; List<Contact> friends; Address address; Map<Integer, Currency> preferredCurrencies; }
/** * @author Oliver Gierke * @author Mark Paluch */ @Data @Document class Customer { @Id ObjectId id = new ObjectId(); String firstname, lastname; public Customer(String firstname, String lastname) { this.firstname = firstname; this.lastname = lastname; } }
/** * @author Christoph Strobl * @currentRead The Core - Peter V. Brett */ @Data @AllArgsConstructor @Document("processes") public class Process { @Id Integer id; State state; int transitionCount; }