尝试通过此方法保存时需要帮助,我的休眠调试未显示任何错误,此方法中没有一个错误捕获
它没有提交,已经尝试了一切,包括来自JPARepositiry的saveAndFlush(),所有可能的注释,检查整个算法和逻辑。我认为这与我的PostgreSQL配置或相关实体之间的双向关系有关。但是,仍然没有任何东西显示在数据库的表中
@RequestMapping(value = "/save-pegawai-status", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePlanningPegawaiStatus(@Valid @RequestBody PlanningPegawaiStatusVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = servicePermohonanStatus.savePlanningPegawaiStatus(vo);
if (CommonUtil.isNotNullOrEmpty(result.get("noRec"))) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} else {
return RestUtil.getJsonResponse(result, HttpStatus.OK);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePlanningPegawaiStatus", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePlanningPegawaiStatus", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
} catch (Exception exp) {
LOGGER.error("Got exception {} when savePlanningPegawaiStatus", exp.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, exp.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
package com.jasamedika.medifirst2000.entities;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import com.jasamedika.medifirst2000.base.BaseTransaction;
import com.jasamedika.medifirst2000.helper.Caption;
@Entity
@Table(name="ListTanggalCuti_T")
public class ListTanggalCuti extends BaseTransaction{
@Caption(value="tgl")
@Column(name="tgl", nullable=true)
private Date tgl;
@Caption(value="Approval Status")
@Column(name="ApprovalStatus", nullable=true)
private Boolean approvalStatus;
@ManyToOne(fetch=FetchType.LAZY)
@Caption(value="Object Planning Pegawai Status")
@JoinColumn(name="ObjectPlanningPegawaiStatusFK")
private PlanningPegawaiStatus planningPegawaiStatus;
@Column(name="ObjectPlanningPegawaiStatusFK", insertable=false, updatable=false)
private String planningPegawaiStatusId;
public Date getTgl() {
return tgl;
}
public void setTgl(Date tgl) {
this.tgl = tgl;
}
public Boolean getApprovalStatus() {
return approvalStatus;
}
public void setApprovalStatus(Boolean approvalStatus) {
this.approvalStatus = approvalStatus;
}
public PlanningPegawaiStatus getPlanningPegawaiStatus() {
return planningPegawaiStatus;
}
public void setPlanningPegawaiStatus(PlanningPegawaiStatus planningPegawaiStatus) {
this.planningPegawaiStatus = planningPegawaiStatus;
}
public String getPlanningPegawaiStatusId() {
return planningPegawaiStatusId;
}
public void setPlanningPegawaiStatusId(String planningPegawaiStatusId) {
this.planningPegawaiStatusId = planningPegawaiStatusId;
}
}
package com.jasamedika.medifirst2000.entities;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import com.jasamedika.medifirst2000.base.BaseTransaction;
import com.jasamedika.medifirst2000.helper.Caption;
@Entity
@Table(name="PlanningPegawaiStatus_T")
public class PlanningPegawaiStatus extends BaseTransaction{
@Caption(value="No Planning")
@Column(name="NoPlanning", length=15, nullable=true)
private String noPlanning;
@ManyToOne(fetch=FetchType.LAZY)
@Caption(value="Object Pegawai")
@JoinColumn(name="ObjectPegawaiFk")
private Pegawai pegawai;
// @ManyToOne(fetch=FetchType.LAZY)
// @Caption(value="Object Jabatan Cuti")
// @JoinColumn(name="ObjectJabatanCutiFk")
// private Jabatan jabatanCuti;
@Column(name="ObjectPegawaiFk", nullable=true, insertable=false, updatable=false)
private Integer pegawaiId;
@ManyToOne(fetch=FetchType.LAZY)
@Caption(value="Object Status Pegawai Plan")
@JoinColumn(name="ObjectStatusPegawaiPlanFk")
private StatusPegawai statusPegawaiPlan;
@Column(name="ObjectStatusPegawaiPlanFk", nullable=true, insertable=false, updatable=false)
private Integer statusPegawaiPlanId;
@OneToMany(cascade=CascadeType.ALL,fetch = FetchType.LAZY, mappedBy = "planningPegawaiStatus", orphanRemoval=true)
private Set<ListTanggalCuti> listTanggal = new HashSet<ListTanggalCuti>();
@ManyToOne(fetch=FetchType.LAZY)
@Caption(value="Object Departemen")
@JoinColumn(name="ObjectDepartemenFk")
private Departemen departemen;
@Column(name="ObjectDepartemenFk", nullable=true, insertable=false, updatable=false)
private Integer departemenId;
@Caption(value="Deskripsi Status Pegawai Plan")
@Column(name="DeskripsiStatusPegawaiPlan", length=1000, nullable=true)
private String deskripsiStatusPegawaiPlan;
@Caption(value="Keterangan Lainya Plan")
@Column(name="KeteranganLainyaPlan", length=1000, nullable=true)
private String keteranganLainyaPlan;
@ManyToOne(fetch=FetchType.LAZY)
@Caption(value="Object No SK")
@JoinColumn(name="ObjectNoSkFk")
private SuratKeputusan noSk;
@Column(name="ObjectNoSkFk", nullable=true, insertable=false, updatable=false)
private Integer noSkId;
@ManyToOne(fetch=FetchType.LAZY)
@Caption(value="Object Status Pegawai Exec")
@JoinColumn(name="ObjectStatusPegawaiExecFk")
private StatusPegawai statusPegawaiExec;
@Column(name="ObjectStatusPegawaiExecFk", nullable=true, insertable=false, updatable=false)
private Integer statusPegawaiExecId;
@Caption(value="Deskripsi Status Pegawai Exec")
@Column(name="DeskripsiStatusPegawaiExec", length=1000, nullable=true)
private String deskripsiStatusPegawaiExec;
@Caption(value="Keterangan Lainya Exec")
@Column(name="KeteranganLainyaExec", length=1000, nullable=true)
private String keteranganLainyaExec;
@Caption(value="Tgl Pengajuan")
@Column(name="TglPengajuan", nullable=true)
private Date tglPengajuan;
@Caption(value="Tgl Keputusan")
@Column(name="TglKeputusan", nullable=true)
private Date tglKeputusan;
@Caption(value="Approval Status")
@Column(name="ApprovalStatus", nullable=true)
private Integer approvalStatus;
@Caption(value="jumlahHari")
@Column(name="jumlahHari", nullable=true)
private Integer jumlahHari;
// @Caption(value="keterangan")
// @Column(name="keterangan", nullable=true)
// private String keterangan;
@Caption(value="Jenis Perawatan")
@Column(name="jenisPerawatan", nullable=true)
private Integer jenisPerawatan;
@Caption(value="Alamat Selama Cuti")
@Column(name="alamatCuti", nullable=true)
private String alamatCuti;
@Caption(value="Nomor Telepon")
@Column(name="nomorTelepon", nullable=true)
private String nomorTelepon;
@Caption(value="Nomor Surat Tugas")
@Column(name="noSuratTugas", nullable=true)
private String noSuratTugas;
@Caption(value="Nomor Nota Dinas")
@Column(name="noNotaDinas", nullable=true)
private String noNotaDinas;
@Caption(value="Tgl Nota Dinas")
@Column(name="TglNotaDinas", nullable=true)
private Date tglNotaDinas;
@Caption(value="Alamat Tugas Dinas")
@Column(name="alamatTugas", nullable=true)
private String alamatTugas;
@ManyToOne(optional=true,fetch=FetchType.LAZY)
@Caption(value="Object Jabatan Pemberi Nota Dinas")
@JoinColumn(name="ObjectJabatanPemberiNotaDinasFk", nullable=true)
private Jabatan jabatanPemberiNotaDinas;
@Column(name="ObjectJabatanPemberiNotaDinasFk", nullable=true, insertable=false, updatable=false)
private Integer jabatanIdPemberiNotaDinas;
@Caption(value="is Cuti Luar Negeri")
@Column(name="isCutiLuarNegeri", nullable=true)
private Boolean isCutiLuarNegeri;
public String getNoPlanning() {
return noPlanning;
}
public void setNoPlanning(String noPlanning) {
this.noPlanning = noPlanning;
}
public Pegawai getPegawai() {
return pegawai;
}
public void setPegawai(Pegawai pegawai) {
this.pegawai = pegawai;
}
public Integer getPegawaiId() {
return pegawaiId;
}
public void setPegawaiId(Integer pegawaiId) {
this.pegawaiId = pegawaiId;
}
// public Jabatan getJabatanCuti() {
// return jabatanCuti;
// }
// public void setJabatanCuti(Jabatan jabatanCuti) {
// this.jabatanCuti = jabatanCuti;
// }
public StatusPegawai getStatusPegawaiPlan() {
return statusPegawaiPlan;
}
public void setStatusPegawaiPlan(StatusPegawai statusPegawaiPlan) {
this.statusPegawaiPlan = statusPegawaiPlan;
}
public Integer getStatusPegawaiPlanId() {
return statusPegawaiPlanId;
}
public void setStatusPegawaiPlanId(Integer statusPegawaiPlanId) {
this.statusPegawaiPlanId = statusPegawaiPlanId;
}
public Departemen getDepartemen() {
return departemen;
}
public void setDepartemen(Departemen departemen) {
this.departemen = departemen;
}
public Integer getDepartemenId() {
return departemenId;
}
public void setDepartemenId(Integer departemenId) {
this.departemenId = departemenId;
}
public String getDeskripsiStatusPegawaiPlan() {
return deskripsiStatusPegawaiPlan;
}
public void setDeskripsiStatusPegawaiPlan(String deskripsiStatusPegawaiPlan) {
this.deskripsiStatusPegawaiPlan = deskripsiStatusPegawaiPlan;
}
public String getKeteranganLainyaPlan() {
return keteranganLainyaPlan;
}
public void setKeteranganLainyaPlan(String keteranganLainyaPlan) {
this.keteranganLainyaPlan = keteranganLainyaPlan;
}
public SuratKeputusan getNoSk() {
return noSk;
}
public void setNoSk(SuratKeputusan noSk) {
this.noSk = noSk;
}
public Integer getNoSkId() {
return noSkId;
}
public void setNoSkId(Integer noSkId) {
this.noSkId = noSkId;
}
public StatusPegawai getStatusPegawaiExec() {
return statusPegawaiExec;
}
public void setStatusPegawaiExec(StatusPegawai statusPegawaiExec) {
this.statusPegawaiExec = statusPegawaiExec;
}
public Integer getStatusPegawaiExecId() {
return statusPegawaiExecId;
}
public void setStatusPegawaiExecId(Integer statusPegawaiExecId) {
this.statusPegawaiExecId = statusPegawaiExecId;
}
public String getDeskripsiStatusPegawaiExec() {
return deskripsiStatusPegawaiExec;
}
public void setDeskripsiStatusPegawaiExec(String deskripsiStatusPegawaiExec) {
this.deskripsiStatusPegawaiExec = deskripsiStatusPegawaiExec;
}
public String getKeteranganLainyaExec() {
return keteranganLainyaExec;
}
public void setKeteranganLainyaExec(String keteranganLainyaExec) {
this.keteranganLainyaExec = keteranganLainyaExec;
}
public Date getTglPengajuan() {
return tglPengajuan;
}
public void setTglPengajuan(Date tglPengajuan) {
this.tglPengajuan = tglPengajuan;
}
public Date getTglKeputusan() {
return tglKeputusan;
}
public void setTglKeputusan(Date tglKeputusan) {
this.tglKeputusan = tglKeputusan;
}
public Integer getApprovalStatus() {
return approvalStatus;
}
public void setApprovalStatus(Integer approvalStatus) {
this.approvalStatus = approvalStatus;
}
public Integer getJumlahHari() {
return jumlahHari;
}
public void setJumlahHari(Integer jumlahHari) {
this.jumlahHari = jumlahHari;
}
public Set<ListTanggalCuti> getListTanggal() {
return listTanggal;
}
public void setListTanggal(Set<ListTanggalCuti> listTanggal) {
this.listTanggal = listTanggal;
}
// public String getKeterangan() {
// return keterangan;
// }
// public void setKeterangan(String keterangan) {
// this.keterangan = keterangan;
// }
public Integer getJenisPerawatan() {
return jenisPerawatan;
}
public void setJenisPerawatan(Integer jenisPerawatan) {
this.jenisPerawatan = jenisPerawatan;
}
public String getAlamatCuti() {
return alamatCuti;
}
public void setAlamatCuti(String alamatCuti) {
this.alamatCuti = alamatCuti;
}
public String getNomorTelepon() {
return nomorTelepon;
}
public void setNomorTelepon(String nomorTelepon) {
this.nomorTelepon = nomorTelepon;
}
public String getNoSuratTugas() {
return noSuratTugas;
}
public void setNoSuratTugas(String noSuratTugas) {
this.noSuratTugas = noSuratTugas;
}
public String getNoNotaDinas() {
return noNotaDinas;
}
public void setNoNotaDinas(String noNotaDinas) {
this.noNotaDinas = noNotaDinas;
}
public Date getTglNotaDinas() {
return tglNotaDinas;
}
public void setTglNotaDinas(Date tglNotaDinas) {
this.tglNotaDinas = tglNotaDinas;
}
public String getAlamatTugas() {
return alamatTugas;
}
public void setAlamatTugas(String alamatTugas) {
this.alamatTugas = alamatTugas;
}
public Jabatan getJabatanPemberiNotaDinas() {
return jabatanPemberiNotaDinas;
}
public void setJabatanPemberiNotaDinas(Jabatan jabatanPemberiNotaDinas) {
this.jabatanPemberiNotaDinas = jabatanPemberiNotaDinas;
}
public Integer getJabatanIdPemberiNotaDinas() {
return jabatanIdPemberiNotaDinas;
}
public void setJabatanIdPemberiNotaDinas(Integer jabatanIdPemberiNotaDinas) {
this.jabatanIdPemberiNotaDinas = jabatanIdPemberiNotaDinas;
}
public Boolean getIsCutiLuarNegeri() {
return isCutiLuarNegeri;
}
public void setIsCutiLuarNegeri(Boolean isCutiLuarNegeri) {
this.isCutiLuarNegeri = isCutiLuarNegeri;
}
}
@Override
@Transactional
public Map<String, Object> savePlanningPegawaiStatus(PlanningPegawaiStatusVO vo) {
Map<String, Object> result = new HashMap<>();
boolean statusTanggalPermohonan = validateTanggalPermohonan(vo.getListTanggal(), vo.getPegawai().getId());
if (CommonUtil.isNotNullOrEmpty(statusTanggalPermohonan) && !statusTanggalPermohonan) {
result.put("bisaCuti", statusTanggalPermohonan);
result.put("status", "Tanggal Permohonan sudah pernah diajukan!"); //Validasi tanggal permohonan yang sudah diajukan
return result;
} else {
Integer day = 0;
if (CommonUtil.isNotNullOrEmpty(vo)) {
PlanningPegawaiStatus planningPegawaiStatus = planningPegawaiStatusConverter.transferVOToModel(vo,
new PlanningPegawaiStatus());
String noPlanning = noUsulan().get("noUsulan").toString();
if (CommonUtil.isNotNullOrEmpty(noPlanning)) {
planningPegawaiStatus.setNoPlanning(noPlanning);
planningPegawaiStatus.setStatusEnabled(true);
if (CommonUtil.isNotNullOrEmpty(vo.getStatusPegawaiPlan())) {
planningPegawaiStatus.setStatusPegawaiPlan(
statusPegawaiConverter.transferVOToModel(vo.getStatusPegawaiPlan(), new StatusPegawai()));
}
if (CommonUtil.isNotNullOrEmpty(vo.getJabatanPemberiNotaDinas())) {
planningPegawaiStatus.setJabatanPemberiNotaDinas(
jabatanConverter.transferVOToModel(vo.getJabatanPemberiNotaDinas(), new Jabatan()));
}
planningPegawaiStatus.setApprovalStatus(0);
if (CommonUtil.isNotNullOrEmpty(vo.getPegawai())) {
planningPegawaiStatus
.setPegawai(pegawaiConverter.transferVOToModel(vo.getPegawai(), new Pegawai()));
}
Set<ListTanggalCuti> listTanggal = new HashSet<ListTanggalCuti>();
for (ListTanggalCutiVO date : vo.getListTanggal()) {
day++;
ListTanggalCuti tanggal = listTanggalConverter.transferVOToModel(date, new ListTanggalCuti());
tanggal.setPlanningPegawaiStatus(planningPegawaiStatus);
tanggal.setStatusEnabled(true);
listTanggal.add(tanggal);
}
planningPegawaiStatus.setJumlahHari(day);
planningPegawaiStatus.setListTanggal(listTanggal);
if (CommonUtil.isNotNullOrEmpty(vo.getDeskripsiStatusPegawaiPlan())) {
planningPegawaiStatus.setDeskripsiStatusPegawaiPlan(vo.getDeskripsiStatusPegawaiPlan());
}
if (CommonUtil.isNotNullOrEmpty(vo.getKeteranganLainyaPlan())) {
planningPegawaiStatus.setKeteranganLainyaPlan(vo.getKeteranganLainyaPlan());
}
//Set Alamat Cuti dan No Telepon
planningPegawaiStatus.setAlamatCuti(vo.getAlamatCuti());
planningPegawaiStatus.setNomorTelepon(vo.getNomorTelepon());
if (CommonUtil.isNotNullOrEmpty(vo.getAlamatTugas())) {
planningPegawaiStatus.setAlamatTugas(vo.getAlamatTugas());
}
if (CommonUtil.isNotNullOrEmpty(vo.getNoSuratTugas())) {
planningPegawaiStatus.setNoSuratTugas(vo.getNoSuratTugas());
}
if (CommonUtil.isNotNullOrEmpty(vo.getNoNotaDinas())) {
planningPegawaiStatus.setNoNotaDinas(vo.getNoNotaDinas());
}
if (CommonUtil.isNotNullOrEmpty(vo.getTglNotaDinas())) {
planningPegawaiStatus.setTglNotaDinas(vo.getTglNotaDinas());
}
planningPegawaiStatus.setIsCutiLuarNegeri(vo.getIsCutiLuarNegeri());
if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus)) {
List<String> listTgl = new ArrayList<>();
planningPegawaiStatus.setStatusEnabled(true);
PlanningPegawaiStatus planningPegawaiStatusResult = planningPegawaiStatusDao
.save(planningPegawaiStatus);
for (ListTanggalCuti listTanggalCuti : planningPegawaiStatusResult.getListTanggal()) {
listTgl.add(listTanggalCuti.getNoRec());
}
result.put("listTgl", listTgl);
result.put("noRec", planningPegawaiStatusResult.getNoRec());
result.put("bisaCuti", statusTanggalPermohonan);
}
}
}
return result;
}
}
PlanningPegawaiStatusVO和ListTanggalCutiVO只是相关的值对象类,transferVOToModel()是一种从值对象类到模型的数据访问方法
我终于意识到,有时它的提交有时不是。然后,当未将其插入数据库时,也返回HttpStatus。创建了一个ERROR_MESSAGE,就像无法从GenericJDBCException中提取ResultSet一样,但它不是来自catch