mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
#2069 - Add ebean-querybean, querybean-generator and kotlin-querybean-generator as modules
This commit is contained in:
1 parent
bc055fea25
commit
038db79737
140 files changed
+11583
No files matched your search
@@ -0,0 +1,16 @@
|
||||
package org.example.domain;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Inheritance;
|
||||
|
||||
@Inheritance
|
||||
@DiscriminatorValue("CAT")
|
||||
@Entity
|
||||
public class ACat extends Animal {
|
||||
|
||||
public ACat(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.example.domain;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Inheritance;
|
||||
|
||||
@Inheritance
|
||||
@DiscriminatorValue("DOG")
|
||||
@Entity
|
||||
public class ADog extends Animal {
|
||||
|
||||
private String registration;
|
||||
|
||||
public ADog(String name, String registration) {
|
||||
super(name);
|
||||
this.registration = registration;
|
||||
}
|
||||
|
||||
public String getRegistration() {
|
||||
return registration;
|
||||
}
|
||||
|
||||
public void setRegistration(String registration) {
|
||||
this.registration = registration;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.example.domain;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Inheritance;
|
||||
|
||||
@Inheritance
|
||||
@DiscriminatorValue("WC")
|
||||
@Entity
|
||||
public class AWildCat extends ACat {
|
||||
|
||||
public AWildCat(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package org.example.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* Address entity bean.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "o_address")
|
||||
public class Address extends BaseModel {
|
||||
|
||||
@Size(max = 100)
|
||||
String line1;
|
||||
|
||||
@Size(max = 100)
|
||||
String line2;
|
||||
|
||||
@Size(max = 100)
|
||||
String city;
|
||||
|
||||
@ManyToOne
|
||||
Country country;
|
||||
|
||||
/**
|
||||
* Create a copy of the address. Used to provide a 'snapshot' of
|
||||
* the shippingAddress for a give order.
|
||||
*/
|
||||
public Address createCopy() {
|
||||
Address copy = new Address();
|
||||
copy.setLine1(line1);
|
||||
copy.setLine2(line2);
|
||||
copy.setCity(city);
|
||||
copy.setCountry(country);
|
||||
return copy;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return id + " " + line1 + " " + line2 + " " + city + " " + country;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return line 1.
|
||||
*/
|
||||
public String getLine1() {
|
||||
return line1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set line 1.
|
||||
*/
|
||||
public void setLine1(String line1) {
|
||||
this.line1 = line1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return line 2.
|
||||
*/
|
||||
public String getLine2() {
|
||||
return line2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set line 2.
|
||||
*/
|
||||
public void setLine2(String line2) {
|
||||
this.line2 = line2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return city.
|
||||
*/
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set city.
|
||||
*/
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return country.
|
||||
*/
|
||||
public Country getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set country.
|
||||
*/
|
||||
public void setCountry(Country country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.example.domain;
|
||||
|
||||
import io.ebean.Model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.Version;
|
||||
|
||||
@Entity
|
||||
@Inheritance
|
||||
public abstract class Animal extends Model {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@Version
|
||||
long version;
|
||||
|
||||
String name;
|
||||
|
||||
public Animal(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package org.example.domain;
|
||||
|
||||
import io.ebean.Model;
|
||||
import io.ebean.annotation.CreatedTimestamp;
|
||||
import io.ebean.annotation.UpdatedTimestamp;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.Version;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* Base domain object with Id, version, whenCreated and whenUpdated.
|
||||
*
|
||||
* <p>
|
||||
* Extending Model to enable the 'active record' style.
|
||||
*
|
||||
* <p>
|
||||
* whenCreated and whenUpdated are generally useful for maintaining external search services (like
|
||||
* elasticsearch) and audit.
|
||||
*/
|
||||
@MappedSuperclass
|
||||
public abstract class BaseModel extends Model {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
@CreatedTimestamp
|
||||
Timestamp whenCreated;
|
||||
|
||||
@UpdatedTimestamp
|
||||
Timestamp whenUpdated;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Timestamp getWhenCreated() {
|
||||
return whenCreated;
|
||||
}
|
||||
|
||||
public void setWhenCreated(Timestamp whenCreated) {
|
||||
this.whenCreated = whenCreated;
|
||||
}
|
||||
|
||||
public Timestamp getWhenUpdated() {
|
||||
return whenUpdated;
|
||||
}
|
||||
|
||||
public void setWhenUpdated(Timestamp whenUpdated) {
|
||||
this.whenUpdated = whenUpdated;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package org.example.domain;
|
||||
|
||||
import io.ebean.annotation.DbArray;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Contact entity bean.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="be_contact")
|
||||
public class Contact extends BaseModel {
|
||||
|
||||
@DbArray
|
||||
List<String> phoneNumbers = new ArrayList();
|
||||
|
||||
@Column(length=50)
|
||||
String firstName;
|
||||
|
||||
@Column(length=50)
|
||||
String lastName;
|
||||
|
||||
@Column(length=200)
|
||||
String email;
|
||||
|
||||
@Column(length=20)
|
||||
String phone;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
Customer customer;
|
||||
|
||||
@OneToMany(mappedBy = "contact")
|
||||
List<ContactNote> notes;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public Contact() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct with a firstName and lastName.
|
||||
*/
|
||||
public Contact(String firstName, String lastName) {
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public Customer getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
public void setCustomer(Customer customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public List<ContactNote> getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setNotes(List<ContactNote> notes) {
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
public List<String> getPhoneNumbers() {
|
||||
return phoneNumbers;
|
||||
}
|
||||
|
||||
public void setPhoneNumbers(List<String> phoneNumbers) {
|
||||
this.phoneNumbers = phoneNumbers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.example.domain;
|
||||
|
||||
import io.ebean.Finder;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class ContactNote extends BaseModel {
|
||||
|
||||
public static final Finder<Long, ContactNote> find = new Finder<>(ContactNote.class);
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
Contact contact;
|
||||
|
||||
String title;
|
||||
|
||||
@Lob
|
||||
String note;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public Contact getContact() {
|
||||
return contact;
|
||||
}
|
||||
|
||||
public void setContact(Contact contact) {
|
||||
this.contact = contact;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package org.example.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* Country entity bean.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="o_country")
|
||||
public class Country {
|
||||
|
||||
@Id
|
||||
//@Size(max=2)
|
||||
String code;
|
||||
|
||||
//@Size(max=60)
|
||||
String name;
|
||||
|
||||
public Country(String code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return code.
|
||||
*/
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set code.
|
||||
*/
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package org.example.domain;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
import io.ebean.annotation.EnumValue;
|
||||
import io.ebean.types.Inet;
|
||||
import org.example.domain.finder.CustomerFinder;
|
||||
import org.example.domain.otherpackage.PhoneNumber;
|
||||
import org.example.domain.otherpackage.ValidEmail;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Customer entity bean.
|
||||
*/
|
||||
@Cache
|
||||
@Entity
|
||||
@Table(name = "be_customer")
|
||||
public class Customer extends BaseModel {
|
||||
|
||||
/**
|
||||
* Convenience Finder for 'active record' style.
|
||||
*/
|
||||
public static final CustomerFinder find = new CustomerFinder();
|
||||
|
||||
public enum Status {
|
||||
@EnumValue("G")
|
||||
GOOD,
|
||||
|
||||
@EnumValue("B")
|
||||
BAD,
|
||||
|
||||
@EnumValue("M")
|
||||
MIDDLING
|
||||
}
|
||||
|
||||
Status status;
|
||||
|
||||
boolean inactive;
|
||||
|
||||
PhoneNumber phoneNumber;
|
||||
|
||||
ValidEmail email;
|
||||
|
||||
@Column(length = 100)
|
||||
String name;
|
||||
|
||||
Date registered;
|
||||
|
||||
Inet currentInet;
|
||||
|
||||
@Column(length = 1000)
|
||||
String comments;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
Address billingAddress;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
Address shippingAddress;
|
||||
|
||||
@OneToMany(mappedBy = "customer", cascade = CascadeType.PERSIST)
|
||||
List<Contact> contacts;
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public boolean isInactive() {
|
||||
return inactive;
|
||||
}
|
||||
|
||||
public void setInactive(boolean inactive) {
|
||||
this.inactive = inactive;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Date getRegistered() {
|
||||
return registered;
|
||||
}
|
||||
|
||||
public void setRegistered(Date registered) {
|
||||
this.registered = registered;
|
||||
}
|
||||
|
||||
public String getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
public void setComments(String comments) {
|
||||
this.comments = comments;
|
||||
}
|
||||
|
||||
public Inet getCurrentInet() {
|
||||
return currentInet;
|
||||
}
|
||||
|
||||
public void setCurrentInet(Inet currentInet) {
|
||||
this.currentInet = currentInet;
|
||||
}
|
||||
|
||||
public Address getBillingAddress() {
|
||||
return billingAddress;
|
||||
}
|
||||
|
||||
public void setBillingAddress(Address billingAddress) {
|
||||
this.billingAddress = billingAddress;
|
||||
}
|
||||
|
||||
public Address getShippingAddress() {
|
||||
return shippingAddress;
|
||||
}
|
||||
|
||||
public void setShippingAddress(Address shippingAddress) {
|
||||
this.shippingAddress = shippingAddress;
|
||||
}
|
||||
|
||||
public List<Contact> getContacts() {
|
||||
return contacts;
|
||||
}
|
||||
|
||||
public void setContacts(List<Contact> contacts) {
|
||||
this.contacts = contacts;
|
||||
}
|
||||
|
||||
public PhoneNumber getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(final PhoneNumber phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public ValidEmail getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(final ValidEmail email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to add a contact to the customer.
|
||||
*/
|
||||
public void addContact(Contact contact) {
|
||||
if (contacts == null) {
|
||||
contacts = new ArrayList<>();
|
||||
}
|
||||
// setting the customer is automatically done when Ebean does
|
||||
// a cascade save from customer to contacts.
|
||||
contact.setCustomer(this);
|
||||
contacts.add(contact);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package org.example.domain;
|
||||
|
||||
import io.ebean.Finder;
|
||||
import io.ebean.Model;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderBy;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.sql.Date;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Order entity bean.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "o_order")
|
||||
public class Order extends BaseModel {
|
||||
|
||||
public static final Finder<Long,Order> find = new Finder<>(Order.class);
|
||||
|
||||
public enum Status {
|
||||
NEW, APPROVED, SHIPPED, COMPLETE
|
||||
}
|
||||
|
||||
Status status;
|
||||
|
||||
Date orderDate;
|
||||
|
||||
Date shipDate;
|
||||
|
||||
@NotNull
|
||||
@ManyToOne
|
||||
Customer customer;
|
||||
|
||||
@ManyToOne
|
||||
Address shippingAddress;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "order")
|
||||
@OrderBy("id asc")
|
||||
List<OrderDetail> details;
|
||||
|
||||
public String toString() {
|
||||
return id + " status:" + status + " customer:" + customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return order date.
|
||||
*/
|
||||
public Date getOrderDate() {
|
||||
return orderDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set order date.
|
||||
*/
|
||||
public void setOrderDate(Date orderDate) {
|
||||
this.orderDate = orderDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return ship date.
|
||||
*/
|
||||
public Date getShipDate() {
|
||||
return shipDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ship date.
|
||||
*/
|
||||
public void setShipDate(Date shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return status.
|
||||
*/
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set status.
|
||||
*/
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return customer.
|
||||
*/
|
||||
public Customer getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set customer.
|
||||
*/
|
||||
public void setCustomer(Customer customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the customer with their current shipping address.
|
||||
*/
|
||||
public void setCustomerWithShipping(Customer customer) {
|
||||
this.customer = customer;
|
||||
this.shippingAddress = customer.getShippingAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return details.
|
||||
*/
|
||||
public List<OrderDetail> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set details.
|
||||
*/
|
||||
public void setDetails(List<OrderDetail> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public void addDetail(OrderDetail detail) {
|
||||
|
||||
if (details == null) {
|
||||
details = new ArrayList<>();
|
||||
}
|
||||
details.add(detail);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package org.example.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* Order Detail entity bean.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "o_order_detail")
|
||||
public class OrderDetail extends BaseModel {
|
||||
|
||||
@ManyToOne
|
||||
Order order;
|
||||
|
||||
Integer orderQty;
|
||||
|
||||
Integer shipQty;
|
||||
|
||||
Double unitPrice;
|
||||
|
||||
@ManyToOne
|
||||
Product product;
|
||||
|
||||
public OrderDetail() {
|
||||
}
|
||||
|
||||
public OrderDetail(Product product, Integer orderQty, Double unitPrice) {
|
||||
this.product = product;
|
||||
this.orderQty = orderQty;
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return order qty.
|
||||
*/
|
||||
public Integer getOrderQty() {
|
||||
return orderQty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set order qty.
|
||||
*/
|
||||
public void setOrderQty(Integer orderQty) {
|
||||
this.orderQty = orderQty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return ship qty.
|
||||
*/
|
||||
public Integer getShipQty() {
|
||||
return shipQty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ship qty.
|
||||
*/
|
||||
public void setShipQty(Integer shipQty) {
|
||||
this.shipQty = shipQty;
|
||||
}
|
||||
|
||||
public Double getUnitPrice() {
|
||||
return unitPrice;
|
||||
}
|
||||
|
||||
public void setUnitPrice(Double unitPrice) {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return order.
|
||||
*/
|
||||
public Order getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set order.
|
||||
*/
|
||||
public void setOrder(Order order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return product.
|
||||
*/
|
||||
public Product getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set product.
|
||||
*/
|
||||
public void setProduct(Product product) {
|
||||
this.product = product;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.example.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* Product entity bean.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "o_product")
|
||||
public class Product extends BaseModel {
|
||||
|
||||
@Size(max = 20)
|
||||
String sku;
|
||||
|
||||
String name;
|
||||
|
||||
/**
|
||||
* Return sku.
|
||||
*/
|
||||
public String getSku() {
|
||||
return sku;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sku.
|
||||
*/
|
||||
public void setSku(String sku) {
|
||||
this.sku = sku;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.example.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SomePojo {
|
||||
|
||||
String name;
|
||||
|
||||
ArrayList<String> foos = new ArrayList<>();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.example.domain.finder;
|
||||
|
||||
import io.ebean.Finder;
|
||||
import org.example.domain.Customer;
|
||||
import org.example.domain.query.QCustomer;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CustomerFinder extends Finder<Long,Customer> {
|
||||
|
||||
public CustomerFinder() {
|
||||
super(Customer.class);
|
||||
}
|
||||
|
||||
public QCustomer typed() {
|
||||
return new QCustomer();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.example.domain.otherpackage;
|
||||
|
||||
public interface Email<T> extends Comparable<T> {
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package org.example.domain.otherpackage;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
@Converter
|
||||
public class PhoneAttributeConverter implements AttributeConverter<PhoneNumber, String> {
|
||||
@Override
|
||||
public String convertToDatabaseColumn(final PhoneNumber attribute) {
|
||||
return attribute.getMsisdn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhoneNumber convertToEntityAttribute(final String dbData) {
|
||||
return new PhoneNumber(dbData);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.example.domain.otherpackage;
|
||||
|
||||
public class PhoneNumber {
|
||||
private final String msisdn;
|
||||
|
||||
public PhoneNumber(final String msisdn) {
|
||||
this.msisdn = msisdn;
|
||||
}
|
||||
|
||||
public String getMsisdn() {
|
||||
return msisdn;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.example.domain.otherpackage;
|
||||
|
||||
public class ValidEmail implements Email<ValidEmail> {
|
||||
private final String emailAddress;
|
||||
|
||||
public ValidEmail(final String emailAddress) {
|
||||
this.emailAddress = emailAddress;
|
||||
}
|
||||
|
||||
public String getEmailAddress() {
|
||||
return emailAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final ValidEmail o) {
|
||||
return emailAddress.compareTo(o.emailAddress);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package org.example.domain.otherpackage;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
@Converter
|
||||
public class ValidEmailAttributeConverter implements AttributeConverter<ValidEmail, String> {
|
||||
@Override
|
||||
public String convertToDatabaseColumn(final ValidEmail attribute) {
|
||||
return attribute.getEmailAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValidEmail convertToEntityAttribute(final String dbData) {
|
||||
return new ValidEmail(dbData);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user