コード例 #1
0
 public Object getObjectForUpdate(
     Session session,
     Object objectToUpdateBeforeChange,
     Object objectToUpdateAfterChange,
     boolean useUOW) {
   ClassDescriptor desc = session.getClassDescriptor(objectToUpdateBeforeChange);
   Record rowBeforeChange =
       desc.getObjectBuilder()
           .buildRow(objectToUpdateBeforeChange, (AbstractSession) session, WriteType.UPDATE);
   Record rowAfterChange =
       desc.getObjectBuilder()
           .buildRow(objectToUpdateAfterChange, (AbstractSession) session, WriteType.UPDATE);
   Record rowChange = new DatabaseRecord();
   getChange(
       rowChange,
       session,
       objectToUpdateBeforeChange,
       objectToUpdateAfterChange,
       desc,
       useUOW,
       WriteType.UPDATE);
   Record rowReturn = getRowForUpdate(rowChange);
   if (rowReturn != null && !rowReturn.isEmpty()) {
     Record row = new DatabaseRecord(rowAfterChange.size());
     row.putAll(rowAfterChange);
     row.putAll(rowReturn);
     return readObjectFromRow(session, desc, row);
   } else {
     return objectToUpdateAfterChange;
   }
 }
コード例 #2
0
 public Object getObjectForInsert(Session session, Object objectToInsert) {
   ClassDescriptor desc = session.getClassDescriptor(objectToInsert);
   Record rowToInsert =
       desc.getObjectBuilder()
           .buildRow(objectToInsert, (AbstractSession) session, WriteType.INSERT);
   Record rowReturn = getRowForInsert(rowToInsert);
   if (rowReturn != null && !rowReturn.isEmpty()) {
     Record row = new DatabaseRecord(rowToInsert.size());
     row.putAll(rowToInsert);
     row.putAll(rowReturn);
     return readObjectFromRow(session, desc, row);
   } else {
     return objectToInsert;
   }
 }