package de.greenrobot.daoexample; import java.util.List; import de.greenrobot.daoexample.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 CUSTOMER. */ public class Customer { private Long id; /** Not-null value. */ private String name; /** Used to resolve relations */ private transient DaoSession daoSession; /** Used for active entity operations. */ private transient CustomerDao myDao; private List<Order> orders; public Customer() { } public Customer(Long id) { this.id = id; } public Customer(Long id, String name) { this.id = id; this.name = name; } /** called by internal mechanisms, do not call yourself. */ public void __setDaoSession(DaoSession daoSession) { this.daoSession = daoSession; myDao = daoSession != null ? daoSession.getCustomerDao() : null; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } /** Not-null value. */ public String getName() { return name; } /** Not-null value; ensure this value is available before it is saved to the database. */ public void setName(String name) { this.name = name; } /** 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<Order> getOrders() { if (orders == null) { if (daoSession == null) { throw new DaoException("Entity is detached from DAO context"); } OrderDao targetDao = daoSession.getOrderDao(); List<Order> ordersNew = targetDao._queryCustomer_Orders(id); synchronized (this) { if(orders == null) { orders = ordersNew; } } } return orders; } /** Resets a to-many relationship, making the next get call to query for a fresh result. */ public synchronized void resetOrders() { orders = 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); } }