示例#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);
 }