Update hibernate interceptor

Remove post flush simpan history login user
This commit is contained in:
Salman Manoe 2024-01-30 13:37:10 +07:00
parent 621581079c
commit 4b7a38e16f
5 changed files with 54 additions and 208 deletions

View File

@ -1,13 +1,12 @@
package com.jasamedika.medifirst2000.dao; package com.jasamedika.medifirst2000.dao;
import java.util.List; import com.jasamedika.medifirst2000.entities.HistoryLoginUser;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.jasamedika.medifirst2000.entities.HistoryLoginUser; import java.util.List;
@Repository("historyLoginUserDao") @Repository("historyLoginUserDao")
public interface HistoryLoginUserDao extends JpaRepository<HistoryLoginUser, Integer> { public interface HistoryLoginUserDao extends JpaRepository<HistoryLoginUser, Integer> {
@ -15,7 +14,4 @@ public interface HistoryLoginUserDao extends JpaRepository<HistoryLoginUser, Int
Page<HistoryLoginUser> findByHistoryLoginId(Integer historyLoginId, Pageable pageable); Page<HistoryLoginUser> findByHistoryLoginId(Integer historyLoginId, Pageable pageable);
List<HistoryLoginUser> findByHistoryLoginId(Integer historyLoginId); List<HistoryLoginUser> findByHistoryLoginId(Integer historyLoginId);
} }

View File

@ -1,36 +1,27 @@
package com.jasamedika.medifirst2000.logging.hibernate.interceptor; package com.jasamedika.medifirst2000.logging.hibernate.interceptor;
import java.io.Serializable; import com.jasamedika.medifirst2000.logging.hibernate.holder.HibernateInterceptorBeansHolder;
import java.util.Iterator;
import org.hibernate.CallbackException;
import org.hibernate.EmptyInterceptor; import org.hibernate.EmptyInterceptor;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import com.jasamedika.medifirst2000.logging.hibernate.holder.HibernateInterceptorBeansHolder; import java.io.Serializable;
/** /**
* *
* @author Syamsu * @author Syamsu
*/ */
//@Component
public class HibernateInterceptor extends EmptyInterceptor { public class HibernateInterceptor extends EmptyInterceptor {
/**
*
*/
private static final long serialVersionUID = 5478574918838397131L; private static final long serialVersionUID = 5478574918838397131L;
@Override @Override
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
String[] propertyNames, Type[] types) { String[] propertyNames, Type[] types) {
HibernateInterceptorBeansHolder.loggingSystemAsynchronous.pushData(entity, id, currentState, previousState, propertyNames, types); HibernateInterceptorBeansHolder.loggingSystemAsynchronous.pushData(entity, id, currentState, previousState,
propertyNames, types);
return true; return true;
} }
@Override @Override
public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) { public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
HibernateInterceptorBeansHolder.loggingSystemAsynchronous.insertData(entity, id, state, propertyNames, types); HibernateInterceptorBeansHolder.loggingSystemAsynchronous.insertData(entity, id, state, propertyNames, types);
@ -38,12 +29,7 @@ public class HibernateInterceptor extends EmptyInterceptor {
} }
public void onDelete( public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types) {
HibernateInterceptorBeansHolder.loggingSystemAsynchronous.deleteData(entity, id, state, propertyNames, types); HibernateInterceptorBeansHolder.loggingSystemAsynchronous.deleteData(entity, id, state, propertyNames, types);
} }
@ -57,9 +43,13 @@ public class HibernateInterceptor extends EmptyInterceptor {
return sql; return sql;
} }
@Override /*
public void postFlush(Iterator entities) throws CallbackException { * Commented by Salman 2024/01/30
HibernateInterceptorBeansHolder.loggingSystemAsynchronous.save(entities); *
} * @Desc: Logging sudah tidak dipakai, migrasi ke laravel
*/
// @Override
// public void postFlush(Iterator entities) throws CallbackException {
// HibernateInterceptorBeansHolder.loggingSystemAsynchronous.save(entities);
// }
} }

View File

@ -1,12 +1,14 @@
package com.jasamedika.medifirst2000.service; package com.jasamedika.medifirst2000.service;
import java.util.Map;
import com.jasamedika.medifirst2000.entities.HistoryLoginUser; import com.jasamedika.medifirst2000.entities.HistoryLoginUser;
import com.jasamedika.medifirst2000.vo.HistoryLoginUserVO; import com.jasamedika.medifirst2000.vo.HistoryLoginUserVO;
import java.util.Map;
public interface HistoryLoginUserService<T> extends BaseVoService<HistoryLoginUser, HistoryLoginUserVO, Integer> { public interface HistoryLoginUserService<T> extends BaseVoService<HistoryLoginUser, HistoryLoginUserVO, Integer> {
Map<String, Object> findByHistoryLoginId(Integer historyLoginId); Map<String, Object> findByHistoryLoginId(Integer historyLoginId);
Map<String, Object> findByHistoryLoginId(Integer historyLoginId, Integer page, Integer limit, String sort, String dir);
Map<String, Object> findByHistoryLoginId(Integer historyLoginId, Integer page, Integer limit, String sort,
String dir);
} }

View File

@ -1,142 +1,68 @@
package com.jasamedika.medifirst2000.entities; package com.jasamedika.medifirst2000.entities;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.base.BaseMaster; import com.jasamedika.medifirst2000.base.BaseMaster;
import com.jasamedika.medifirst2000.helper.Caption; import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;
import static javax.persistence.FetchType.LAZY;
import static javax.persistence.GenerationType.SEQUENCE;
/** /**
* class HistoryLoginUser * class HistoryLoginUser
* *
* @author Generator * @author Generator
*/ */
@Getter
@Setter
@Entity @Entity
@Table(name = "HistoryLoginUser_S") @Table(name = "HistoryLoginUser_S")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" }) @JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class HistoryLoginUser extends BaseMaster { public class HistoryLoginUser extends BaseMaster {
private static final long serialVersionUID = -8555810951596017573L;
@Id @Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "public.historyloginuser_m_id_seq") @GeneratedValue(strategy = SEQUENCE, generator = "public.historyloginuser_m_id_seq")
@javax.persistence.SequenceGenerator(name = "public.historyloginuser_m_id_seq", sequenceName = "public.historyloginuser_m_id_seq", allocationSize = 1) @SequenceGenerator(name = "public.historyloginuser_m_id_seq", sequenceName = "public.historyloginuser_m_id_seq", allocationSize = 1)
@Column(name = "id") @Column(name = "id")
protected Integer id; protected Integer id;
public Integer getId() { @Column(name = "DetailDataCRUD")
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "DetailDataCRUD", nullable = true)
@Caption(value = "Detail Data C R U D") @Caption(value = "Detail Data C R U D")
private String detailDataCRUD; private String detailDataCRUD;
public void setDetailDataCRUD(String detailDataCRUD) {
this.detailDataCRUD = detailDataCRUD;
}
public String getDetailDataCRUD() {
return this.detailDataCRUD;
}
@Column(name = "isCRUD", nullable = false, length = 1) @Column(name = "isCRUD", nullable = false, length = 1)
@Caption(value = "Is C R U D") @Caption(value = "Is C R U D")
private String isCRUD; private String isCRUD;
public void setIsCRUD(String isCRUD) { @Column(name = "NamaObjekCRUD")
this.isCRUD = isCRUD;
}
public String getIsCRUD() {
return this.isCRUD;
}
@Column(name = "NamaObjekCRUD", nullable = true, length = 255)
@Caption(value = "Nama Objek C R U D") @Caption(value = "Nama Objek C R U D")
private String namaObjekCRUD; private String namaObjekCRUD;
public void setNamaObjekCRUD(String namaObjekCRUD) {
this.namaObjekCRUD = namaObjekCRUD;
}
public String getNamaObjekCRUD() {
return this.namaObjekCRUD;
}
@NotNull(message = "No Record tidak boleh kosong")
@Column(name = "NoRecord", nullable = false, length = 50) @Column(name = "NoRecord", nullable = false, length = 50)
@NotNull(message = "No Record tidak boleh kosong")
@Caption(value = "No Record") @Caption(value = "No Record")
private String noRecord; private String noRecord;
public void setNoRecord(String noRecord) { @Column(name = "TglCRUDin")
this.noRecord = noRecord;
}
public String getNoRecord() {
return this.noRecord;
}
@Column(name = "TglCRUDin", nullable = true)
@Caption(value = "Tanggal C R U Din") @Caption(value = "Tanggal C R U Din")
private Date tglCRUDin; private Date tglCRUDin;
public void setTglCRUDin(Date tglCRUDin) { @Column(name = "TglCRUDout")
this.tglCRUDin = tglCRUDin;
}
public Date getTglCRUDin() {
return this.tglCRUDin;
}
@Column(name = "TglCRUDout", nullable = true)
@Caption(value = "Tanggal C R U Dout") @Caption(value = "Tanggal C R U Dout")
private Date tglCRUDout; private Date tglCRUDout;
public void setTglCRUDout(Date tglCRUDout) { @ManyToOne(fetch = LAZY)
this.tglCRUDout = tglCRUDout;
}
public Date getTglCRUDout() {
return this.tglCRUDout;
}
@ManyToOne
@JoinColumn(name = "ObjectHistoryLoginFk") @JoinColumn(name = "ObjectHistoryLoginFk")
@NotNull(message = "Kd History Login tidak boleh kosong") @NotNull(message = "Kd History Login tidak boleh kosong")
@Caption(value = "Object History Login") @Caption(value = "Object History Login")
private HistoryLoginModulAplikasi historyLoginModulAplikasi; private HistoryLoginModulAplikasi historyLoginModulAplikasi;
public void setHistoryLoginModulAplikasi(HistoryLoginModulAplikasi historyLoginModulAplikasi) {
this.historyLoginModulAplikasi = historyLoginModulAplikasi;
}
public HistoryLoginModulAplikasi getHistoryLoginModulAplikasi() {
return this.historyLoginModulAplikasi;
}
@Column(name = "ObjectHistoryLoginFk", insertable = false, updatable = false) @Column(name = "ObjectHistoryLoginFk", insertable = false, updatable = false)
private Integer historyLoginId; private Integer historyLoginId;
public void setHistoryLoginId(Integer historyLoginId){
this.historyLoginId = historyLoginId;
}
public Integer getHistoryLoginId(){
return historyLoginId;
}
} }

View File

@ -1,101 +1,33 @@
package com.jasamedika.medifirst2000.vo; package com.jasamedika.medifirst2000.vo;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.jasamedika.medifirst2000.base.vo.BaseMasterVO; import com.jasamedika.medifirst2000.base.vo.BaseMasterVO;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
/** /**
* class HistoryLoginUser * class HistoryLoginUser
* *
* @author Generator * @author Generator
*/ */
@JsonInclude(Include.ALWAYS) @Getter
@Setter
public class HistoryLoginUserVO extends BaseMasterVO { public class HistoryLoginUserVO extends BaseMasterVO {
/**
*
*/
private static final long serialVersionUID = -6774220356263220981L;
private String detailDataCRUD; private String detailDataCRUD;
private String isCRUD; private String isCRUD;
public void setIsCRUD(String isCRUD) {
this.isCRUD = isCRUD;
}
public String getIsCRUD(){
return this.isCRUD;
}
private HistoryLoginModulAplikasiVO historyLogin; private HistoryLoginModulAplikasiVO historyLogin;
public void setHistoryLogin(HistoryLoginModulAplikasiVO historyLogin) {
this.historyLogin = historyLogin;
}
public HistoryLoginModulAplikasiVO getHistoryLogin(){
return this.historyLogin;
}
public Integer getHistoryLoginId() {
return historyLoginId;
}
public void setHistoryLoginId(Integer historyLoginId) {
this.historyLoginId = historyLoginId;
}
private Integer historyLoginId; private Integer historyLoginId;
private String namaObjekCRUD; private String namaObjekCRUD;
public void setNamaObjekCRUD(String namaObjekCRUD) {
this.namaObjekCRUD = namaObjekCRUD;
}
public String getNamaObjekCRUD(){
return this.namaObjekCRUD;
}
private String noRecord; private String noRecord;
public void setNoRecord(String noRecord) {
this.noRecord = noRecord;
}
public String getNoRecord(){
return this.noRecord;
}
private Date tglCRUDin; private Date tglCRUDin;
public void setTglCRUDin(Date tglCRUDin) {
this.tglCRUDin = tglCRUDin;
}
public Date getTglCRUDin(){
return this.tglCRUDin;
}
private Date tglCRUDout; private Date tglCRUDout;
public void setTglCRUDout(Date tglCRUDout) {
this.tglCRUDout = tglCRUDout;
} }
public Date getTglCRUDout(){
return this.tglCRUDout;
}
public String getDetailDataCRUD() {
return detailDataCRUD;
}
public void setDetailDataCRUD(String detailDataCRUD) {
this.detailDataCRUD = detailDataCRUD;
}
}