/** * Insert. * * @throws Exception * @throws SQLException the SQL exception */ public void insert() throws Exception { insertPreCheck(); insertParents(); if (isNewInstance()) { EntityManagerHelper.getEntityManager().persist(this); } insertChildren(); }
/** * This does not insert into the database. This call EntityManager merge. * * @throws Exception */ public DataAccessObject save() throws Exception { if (isNewInstance()) { insert(); } else if (changes != null && changes.size() > 0) { EntityManagerHelper.getEntityManager().merge(this); changes.clear(); } return this; }
/** * Refresh. * * @return true, if refresh * @throws SQLException the SQL exception */ public void refresh() { EntityManagerHelper.getEntityManager().refresh(this); }
/** * Checks if is new instance. * * @return true, if is new instance */ public boolean isNewInstance() { return EntityManagerHelper.getEntityManager() == null || !EntityManagerHelper.getEntityManager().contains(this); }
public void delete() { EntityManagerHelper.getEntityManager().remove(this); }