package com.pinecone.technology.mcommerce.learning.android.chapter06.example.dao;
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_LINE.
*/
public class InvoiceLine {
private Long id;
private long InvoiceId;
private long TrackId;
private double UnitPrice;
private Long Quantity;
/** Used to resolve relations */
private transient DaoSession daoSession;
/** Used for active entity operations. */
private transient InvoiceLineDao myDao;
private Invoice invoice;
private Long invoice__resolvedKey;
public InvoiceLine() {
}
public InvoiceLine(Long id) {
this.id = id;
}
public InvoiceLine(Long id, long InvoiceId, long TrackId, double UnitPrice, Long Quantity) {
this.id = id;
this.InvoiceId = InvoiceId;
this.TrackId = TrackId;
this.UnitPrice = UnitPrice;
this.Quantity = Quantity;
}
/** called by internal mechanisms, do not call yourself. */
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getInvoiceLineDao() : null;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public long getInvoiceId() {
return InvoiceId;
}
public void setInvoiceId(long InvoiceId) {
this.InvoiceId = InvoiceId;
}
public long getTrackId() {
return TrackId;
}
public void setTrackId(long TrackId) {
this.TrackId = TrackId;
}
public double getUnitPrice() {
return UnitPrice;
}
public void setUnitPrice(double UnitPrice) {
this.UnitPrice = UnitPrice;
}
public Long getQuantity() {
return Quantity;
}
public void setQuantity(Long Quantity) {
this.Quantity = Quantity;
}
/** To-one relationship, resolved on first access. */
public Invoice getInvoice() {
long __key = this.InvoiceId;
if (invoice__resolvedKey == null || !invoice__resolvedKey.equals(__key)) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
InvoiceDao targetDao = daoSession.getInvoiceDao();
Invoice invoiceNew = targetDao.load(__key);
synchronized (this) {
invoice = invoiceNew;
invoice__resolvedKey = __key;
}
}
return invoice;
}
public void setInvoice(Invoice invoice) {
if (invoice == null) {
throw new DaoException("To-one property 'InvoiceId' has not-null constraint; cannot set to-one to null");
}
synchronized (this) {
this.invoice = invoice;
InvoiceId = invoice.getId();
invoice__resolvedKey = InvoiceId;
}
}
/** 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);
}
}