Пример #1
0
 /**
  * Insert.
  *
  * @throws Exception
  * @throws SQLException the SQL exception
  */
 public void insert() throws Exception {
   insertPreCheck();
   insertParents();
   if (isNewInstance()) {
     EntityManagerHelper.getEntityManager().persist(this);
   }
   insertChildren();
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 /**
  * Refresh.
  *
  * @return true, if refresh
  * @throws SQLException the SQL exception
  */
 public void refresh() {
   EntityManagerHelper.getEntityManager().refresh(this);
 }
Пример #4
0
 /**
  * Checks if is new instance.
  *
  * @return true, if is new instance
  */
 public boolean isNewInstance() {
   return EntityManagerHelper.getEntityManager() == null
       || !EntityManagerHelper.getEntityManager().contains(this);
 }
Пример #5
0
 public void delete() {
   EntityManagerHelper.getEntityManager().remove(this);
 }