package com.pinecone.technology.mcommerce.learning.android.chapter06.example.dao;
import java.util.List;
import com.pinecone.technology.mcommerce.learning.android.chapter06.example.dao.DaoSession;
import de.greenrobot.dao.DaoException;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit.
/**
* Entity mapped to table INVOICE.
*/
public class Invoice {
private Long id;
private java.util.Date InvoiceDate;
private long CustomerId;
private String BillingAddress;
private String BillingCity;
private String BillingState;
private String BillingCountry;
private String BillingPostalCode;
private Double Total;
/** Used to resolve relations */
private transient DaoSession daoSession;
/** Used for active entity operations. */
private transient InvoiceDao myDao;
private Customer customer;
private Long customer__resolvedKey;
private List<InvoiceLine> InvoiceLines;
public Invoice() {
}
public Invoice(Long id) {
this.id = id;
}
public Invoice(Long id, java.util.Date InvoiceDate, long CustomerId, String BillingAddress, String BillingCity, String BillingState, String BillingCountry, String BillingPostalCode, Double Total) {
this.id = id;
this.InvoiceDate = InvoiceDate;
this.CustomerId = CustomerId;
this.BillingAddress = BillingAddress;
this.BillingCity = BillingCity;
this.BillingState = BillingState;
this.BillingCountry = BillingCountry;
this.BillingPostalCode = BillingPostalCode;
this.Total = Total;
}
/** called by internal mechanisms, do not call yourself. */
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getInvoiceDao() : null;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public java.util.Date getInvoiceDate() {
return InvoiceDate;
}
public void setInvoiceDate(java.util.Date InvoiceDate) {
this.InvoiceDate = InvoiceDate;
}
public long getCustomerId() {
return CustomerId;
}
public void setCustomerId(long CustomerId) {
this.CustomerId = CustomerId;
}
public String getBillingAddress() {
return BillingAddress;
}
public void setBillingAddress(String BillingAddress) {
this.BillingAddress = BillingAddress;
}
public String getBillingCity() {
return BillingCity;
}
public void setBillingCity(String BillingCity) {
this.BillingCity = BillingCity;
}
public String getBillingState() {
return BillingState;
}
public void setBillingState(String BillingState) {
this.BillingState = BillingState;
}
public String getBillingCountry() {
return BillingCountry;
}
public void setBillingCountry(String BillingCountry) {
this.BillingCountry = BillingCountry;
}
public String getBillingPostalCode() {
return BillingPostalCode;
}
public void setBillingPostalCode(String BillingPostalCode) {
this.BillingPostalCode = BillingPostalCode;
}
public Double getTotal() {
return Total;
}
public void setTotal(Double Total) {
this.Total = Total;
}
/** To-one relationship, resolved on first access. */
public Customer getCustomer() {
long __key = this.CustomerId;
if (customer__resolvedKey == null || !customer__resolvedKey.equals(__key)) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
CustomerDao targetDao = daoSession.getCustomerDao();
Customer customerNew = targetDao.load(__key);
synchronized (this) {
customer = customerNew;
customer__resolvedKey = __key;
}
}
return customer;
}
public void setCustomer(Customer customer) {
if (customer == null) {
throw new DaoException("To-one property 'CustomerId' has not-null constraint; cannot set to-one to null");
}
synchronized (this) {
this.customer = customer;
CustomerId = customer.getId();
customer__resolvedKey = CustomerId;
}
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<InvoiceLine> getInvoiceLines() {
if (InvoiceLines == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
InvoiceLineDao targetDao = daoSession.getInvoiceLineDao();
List<InvoiceLine> InvoiceLinesNew = targetDao._queryInvoice_InvoiceLines(id);
synchronized (this) {
if(InvoiceLines == null) {
InvoiceLines = InvoiceLinesNew;
}
}
}
return InvoiceLines;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetInvoiceLines() {
InvoiceLines = null;
}
/** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */
public void delete() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.delete(this);
}
/** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */
public void update() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.update(this);
}
/** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */
public void refresh() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.refresh(this);
}
}