@Override public void bind(final SQLStatement<?> q, final EntityHistoryBinder bind, final EntityHistoryModelDao<M, E> history) { try { // Emulate @BindBean final M arg = history.getEntity(); final BeanInfo infos = Introspector.getBeanInfo(arg.getClass()); final PropertyDescriptor[] props = infos.getPropertyDescriptors(); for (final PropertyDescriptor prop : props) { q.bind(prop.getName(), prop.getReadMethod().invoke(arg)); } q.bind("id", history.getId()); q.bind("targetRecordId", history.getTargetRecordId()); q.bind("changeType", history.getChangeType().toString()); } catch (IntrospectionException e) { logger.warn(e.getMessage()); } catch (InvocationTargetException e) { logger.warn(e.getMessage()); } catch (IllegalAccessException e) { logger.warn(e.getMessage()); } } };
private Long insertHistory(final Long entityRecordId, final M entityModelDao, final ChangeType changeType, final InternalCallContext context) { final EntityHistoryModelDao<M, E> history = new EntityHistoryModelDao<M, E>(entityModelDao, entityRecordId, changeType, clock.getUTCNow()); sqlDao.addHistoryFromTransaction(history, context); final NonEntitySqlDao transactional = sqlDao.become(NonEntitySqlDao.class); /* return transactional.getLastHistoryRecordId(entityRecordId, entityModelDao.getHistoryTableName().getTableName()); */ return nonEntityDao.retrieveLastHistoryRecordIdFromTransaction(entityRecordId, entityModelDao.getHistoryTableName(), transactional); }