@PersistenceContext
private EntityManager entityManager;
@Transactional
public LeaveJpaEntity newLeave(DelegateExecution execution) {
LeaveJpaEntity leave = new LeaveJpaEntity();
leave.setProcessInstanceId(execution.getProcessInstanceId());
leave.setUserId(execution.getVariable("applyUserId").toString());
leave.setStartTime((Date) execution.getVariable("startTime"));
leave.setEndTime((Date) execution.getVariable("endTime"));
leave.setLeaveType(execution.getVariable("leaveType").toString());
leave.setReason(execution.getVariable("reason").toString());
leave.setApplyTime(new Date());
entityManager.persist(leave);
return leave;
}