java - Hibernate 使用 findOne 和 findById 无法看到数据库中更新后触发器对记录所做的更改

标签 java spring hibernate spring-data-jpa spring-data

我在我的项目中使用 Spring boot 1.5.22、Spring data 和 Hibernate 5.2.18。 当我使用 Dao 保存实体对象时:

platDao.save(plat);

数据库中正在执行 BEFORE INSERT 类型的触发器,该触发器正在数据库字段中插入多个文档。当我在数据库工具中使用 SQL 从数据库中的表中进行选择时,我可以看到该字段中的值。但是当我使用 hibernate 和 findOne 方法获取此记录时,我在此字段中看到 null:

Platnosc plat = platDao.findOne(platId);

我也尝试过这个:

Platnosc plat = platDao.findById(platId);

但是结果是一样的,触发器设置的字段为空。

我的服务代码:

public List<Platnosc> createDocumentForInvoice(Integer fakturaId) {

    AuthUser user = loginMgr.getLoggedUser();

    Platnosc plat = Platnosc.builder()
            // I don't set field platnoscNr here it is null
            .build();

    platDao.save(plat);

    return plat;
}

我的 Controller 代码:

public Response createDocumentForInvoice(
        @RequestParam(value = "fakturaId", required = true) Integer fakturaId) {

    List<Platnosc> platList = platMgr.createDocumentForInvoice(fakturaId);

    // after this I can see in database value of field platnoscNr which was inserted by trigger

    String platNr = platList.stream()
            .map(p -> {
                Platnosc plat = platDao.findById(p.getPlatnoscId());     
                return String.format("%s nr %s",
                        platMgr.getRodzajTextForPlatnoscRodzaj(plat.getPlatnoscRodzaj()),
                        plat.getPlatnoscNr());
            })
            .collect(Collectors.joining(", "));

    return Response.ok(platList.size() == 0
            ? "No document was created"
            : "Created documents: " + platNr)
            .build();
}

响应是:

“已创建文档:信用卡编号为空,转账编号为空,其他付款编号为空”

我的 DEGUG.log:

    // ....
2019-10-10 17:29:33 - Participating in existing transaction
2019-10-10 17:29:33 - insert into PLATNOSC (BANK_ID, EMPLOYEE_ID, FAKTURA_ID, FAKTURA_ID1, FIRMA_ID, GRUPA_ID, KASA_ID, MELDUNEK_ID, OSOBA_ID, PLATNOSC_DATA, PLATNOSC_DATA_KARTY, PLATNOSC_DEKRET_ID, PLATNOSC_FK_NR, PLATNOSC_FORPLA, PLATNOSC_KOD_SYSTEMU, PLATNOSC_KWOTA, PLATNOSC_NR, PLATNOSC_NUMER_KARTY, PLATNOSC_OPIS, PLATNOSC_PREFIX, PLATNOSC_RODZAJ, PLATNOSC_RODZAJ_KARTY_ID, PLATNOSC_STATUS, PLATNOSC_STWORZ_ZALICZKE, PLATNOSC_USED, PLATNOSC_Z_PLATNOSC_ID, PLATONLINE_ID, POKOJ_ID, RACHOTW_ID, REZERWACJA_ID, WALUTA_ID, ZALICZKA_ID, ZMIANA_ID, PLATNOSC_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2019-10-10 17:29:33 - select platnosc0_.PLATNOSC_ID as PLATNOSC1_90_, platnosc0_.BANK_ID as BANK_ID2_90_, platnosc0_.EMPLOYEE_ID as EMPLOYEE3_90_, platnosc0_.FAKTURA_ID as FAKTURA_4_90_, platnosc0_.FAKTURA_ID1 as FAKTURA_5_90_, platnosc0_.FIRMA_ID as FIRMA_ID6_90_, platnosc0_.GRUPA_ID as GRUPA_ID7_90_, platnosc0_.KASA_ID as KASA_ID8_90_, platnosc0_.MELDUNEK_ID as MELDUNEK9_90_, platnosc0_.OSOBA_ID as OSOBA_I10_90_, platnosc0_.PLATNOSC_DATA as PLATNOS11_90_, platnosc0_.PLATNOSC_DATA_KARTY as PLATNOS12_90_, platnosc0_.PLATNOSC_DEKRET_ID as PLATNOS13_90_, platnosc0_.PLATNOSC_FK_NR as PLATNOS14_90_, platnosc0_.PLATNOSC_FORPLA as PLATNOS15_90_, platnosc0_.PLATNOSC_KOD_SYSTEMU as PLATNOS16_90_, platnosc0_.PLATNOSC_KWOTA as PLATNOS17_90_, platnosc0_.PLATNOSC_NR as PLATNOS18_90_, platnosc0_.PLATNOSC_NUMER_KARTY as PLATNOS19_90_, platnosc0_.PLATNOSC_OPIS as PLATNOS20_90_, platnosc0_.PLATNOSC_PREFIX as PLATNOS21_90_, platnosc0_.PLATNOSC_RODZAJ as PLATNOS22_90_, platnosc0_.PLATNOSC_RODZAJ_KARTY_ID as PLATNOS23_90_, platnosc0_.PLATNOSC_STATUS as PLATNOS24_90_, platnosc0_.PLATNOSC_STWORZ_ZALICZKE as PLATNOS25_90_, platnosc0_.PLATNOSC_USED as PLATNOS26_90_, platnosc0_.PLATNOSC_Z_PLATNOSC_ID as PLATNOS27_90_, platnosc0_.PLATONLINE_ID as PLATONL28_90_, platnosc0_.POKOJ_ID as POKOJ_I29_90_, platnosc0_.RACHOTW_ID as RACHOTW30_90_, platnosc0_.REZERWACJA_ID as REZERWA31_90_, platnosc0_.WALUTA_ID as WALUTA_32_90_, platnosc0_.ZALICZKA_ID as ZALICZK33_90_, platnosc0_.ZMIANA_ID as ZMIANA_34_90_ from PLATNOSC platnosc0_ where platnosc0_.FAKTURA_ID=?
2019-10-10 17:29:33 - Found thread-bound EntityManager [SessionImpl(PersistenceContext[entityKeys=[EntityKey[ekoncept.entity.Platnosc#59905], EntityKey[ekoncept.entity.Faktura#141935], EntityKey[ekoncept.entity.Platnosc#59903], EntityKey[ekoncept.entity.Platnosc#59904], EntityKey[ekoncept.entity.Stale#101]],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])] for JPA transaction
2019-10-10 17:29:33 - Participating in existing transaction
2019-10-10 17:29:33 - select platnosc0_.PLATNOSC_ID as PLATNOSC1_90_, platnosc0_.BANK_ID as BANK_ID2_90_, platnosc0_.EMPLOYEE_ID as EMPLOYEE3_90_, platnosc0_.FAKTURA_ID as FAKTURA_4_90_, platnosc0_.FAKTURA_ID1 as FAKTURA_5_90_, platnosc0_.FIRMA_ID as FIRMA_ID6_90_, platnosc0_.GRUPA_ID as GRUPA_ID7_90_, platnosc0_.KASA_ID as KASA_ID8_90_, platnosc0_.MELDUNEK_ID as MELDUNEK9_90_, platnosc0_.OSOBA_ID as OSOBA_I10_90_, platnosc0_.PLATNOSC_DATA as PLATNOS11_90_, platnosc0_.PLATNOSC_DATA_KARTY as PLATNOS12_90_, platnosc0_.PLATNOSC_DEKRET_ID as PLATNOS13_90_, platnosc0_.PLATNOSC_FK_NR as PLATNOS14_90_, platnosc0_.PLATNOSC_FORPLA as PLATNOS15_90_, platnosc0_.PLATNOSC_KOD_SYSTEMU as PLATNOS16_90_, platnosc0_.PLATNOSC_KWOTA as PLATNOS17_90_, platnosc0_.PLATNOSC_NR as PLATNOS18_90_, platnosc0_.PLATNOSC_NUMER_KARTY as PLATNOS19_90_, platnosc0_.PLATNOSC_OPIS as PLATNOS20_90_, platnosc0_.PLATNOSC_PREFIX as PLATNOS21_90_, platnosc0_.PLATNOSC_RODZAJ as PLATNOS22_90_, platnosc0_.PLATNOSC_RODZAJ_KARTY_ID as PLATNOS23_90_, platnosc0_.PLATNOSC_STATUS as PLATNOS24_90_, platnosc0_.PLATNOSC_STWORZ_ZALICZKE as PLATNOS25_90_, platnosc0_.PLATNOSC_USED as PLATNOS26_90_, platnosc0_.PLATNOSC_Z_PLATNOSC_ID as PLATNOS27_90_, platnosc0_.PLATONLINE_ID as PLATONL28_90_, platnosc0_.POKOJ_ID as POKOJ_I29_90_, platnosc0_.RACHOTW_ID as RACHOTW30_90_, platnosc0_.REZERWACJA_ID as REZERWA31_90_, platnosc0_.WALUTA_ID as WALUTA_32_90_, platnosc0_.ZALICZKA_ID as ZALICZK33_90_, platnosc0_.ZMIANA_ID as ZMIANA_34_90_ from PLATNOSC platnosc0_ where platnosc0_.FAKTURA_ID=?
2019-10-10 17:29:33 - Found thread-bound EntityManager [SessionImpl(PersistenceContext[entityKeys=[EntityKey[ekoncept.entity.Platnosc#59905], EntityKey[ekoncept.entity.Faktura#141935], EntityKey[ekoncept.entity.Platnosc#59903], EntityKey[ekoncept.entity.Platnosc#59904], EntityKey[ekoncept.entity.Stale#101]],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])] for JPA transaction
2019-10-10 17:29:33 - Participating in existing transaction
2019-10-10 17:29:33 - select platnosc0_.PLATNOSC_ID as PLATNOSC1_90_, platnosc0_.BANK_ID as BANK_ID2_90_, platnosc0_.EMPLOYEE_ID as EMPLOYEE3_90_, platnosc0_.FAKTURA_ID as FAKTURA_4_90_, platnosc0_.FAKTURA_ID1 as FAKTURA_5_90_, platnosc0_.FIRMA_ID as FIRMA_ID6_90_, platnosc0_.GRUPA_ID as GRUPA_ID7_90_, platnosc0_.KASA_ID as KASA_ID8_90_, platnosc0_.MELDUNEK_ID as MELDUNEK9_90_, platnosc0_.OSOBA_ID as OSOBA_I10_90_, platnosc0_.PLATNOSC_DATA as PLATNOS11_90_, platnosc0_.PLATNOSC_DATA_KARTY as PLATNOS12_90_, platnosc0_.PLATNOSC_DEKRET_ID as PLATNOS13_90_, platnosc0_.PLATNOSC_FK_NR as PLATNOS14_90_, platnosc0_.PLATNOSC_FORPLA as PLATNOS15_90_, platnosc0_.PLATNOSC_KOD_SYSTEMU as PLATNOS16_90_, platnosc0_.PLATNOSC_KWOTA as PLATNOS17_90_, platnosc0_.PLATNOSC_NR as PLATNOS18_90_, platnosc0_.PLATNOSC_NUMER_KARTY as PLATNOS19_90_, platnosc0_.PLATNOSC_OPIS as PLATNOS20_90_, platnosc0_.PLATNOSC_PREFIX as PLATNOS21_90_, platnosc0_.PLATNOSC_RODZAJ as PLATNOS22_90_, platnosc0_.PLATNOSC_RODZAJ_KARTY_ID as PLATNOS23_90_, platnosc0_.PLATNOSC_STATUS as PLATNOS24_90_, platnosc0_.PLATNOSC_STWORZ_ZALICZKE as PLATNOS25_90_, platnosc0_.PLATNOSC_USED as PLATNOS26_90_, platnosc0_.PLATNOSC_Z_PLATNOSC_ID as PLATNOS27_90_, platnosc0_.PLATONLINE_ID as PLATONL28_90_, platnosc0_.POKOJ_ID as POKOJ_I29_90_, platnosc0_.RACHOTW_ID as RACHOTW30_90_, platnosc0_.REZERWACJA_ID as REZERWA31_90_, platnosc0_.WALUTA_ID as WALUTA_32_90_, platnosc0_.ZALICZKA_ID as ZALICZK33_90_, platnosc0_.ZMIANA_ID as ZMIANA_34_90_ from PLATNOSC platnosc0_ where platnosc0_.FAKTURA_ID1=?
2019-10-10 17:29:33 - Initiating transaction commit
2019-10-10 17:29:33 - Committing JPA transaction on EntityManager [SessionImpl(PersistenceContext[entityKeys=[EntityKey[ekoncept.entity.Platnosc#59905], EntityKey[ekoncept.entity.Platnosc#59858], EntityKey[ekoncept.entity.Faktura#141935], EntityKey[ekoncept.entity.Platnosc#59903], EntityKey[ekoncept.entity.Platnosc#59904], EntityKey[ekoncept.entity.Stale#101]],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])]
2019-10-10 17:29:33 - Not closing pre-bound JPA EntityManager after transaction
    // here is findById() method called
2019-10-10 17:29:46 - Found thread-bound EntityManager [SessionImpl(PersistenceContext[entityKeys=[EntityKey[ekoncept.entity.Platnosc#59905], EntityKey[ekoncept.entity.Platnosc#59858], EntityKey[ekoncept.entity.Faktura#141935], EntityKey[ekoncept.entity.Platnosc#59903], EntityKey[ekoncept.entity.Platnosc#59904], EntityKey[ekoncept.entity.Stale#101]],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])] for JPA transaction
2019-10-10 17:29:46 - Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.findById]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2019-10-10 17:29:46 - Exposing JPA transaction as JDBC transaction [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@6f808572]
2019-10-10 17:29:46 - select platnosc0_.PLATNOSC_ID as PLATNOSC1_90_, platnosc0_.BANK_ID as BANK_ID2_90_, platnosc0_.EMPLOYEE_ID as EMPLOYEE3_90_, platnosc0_.FAKTURA_ID as FAKTURA_4_90_, platnosc0_.FAKTURA_ID1 as FAKTURA_5_90_, platnosc0_.FIRMA_ID as FIRMA_ID6_90_, platnosc0_.GRUPA_ID as GRUPA_ID7_90_, platnosc0_.KASA_ID as KASA_ID8_90_, platnosc0_.MELDUNEK_ID as MELDUNEK9_90_, platnosc0_.OSOBA_ID as OSOBA_I10_90_, platnosc0_.PLATNOSC_DATA as PLATNOS11_90_, platnosc0_.PLATNOSC_DATA_KARTY as PLATNOS12_90_, platnosc0_.PLATNOSC_DEKRET_ID as PLATNOS13_90_, platnosc0_.PLATNOSC_FK_NR as PLATNOS14_90_, platnosc0_.PLATNOSC_FORPLA as PLATNOS15_90_, platnosc0_.PLATNOSC_KOD_SYSTEMU as PLATNOS16_90_, platnosc0_.PLATNOSC_KWOTA as PLATNOS17_90_, platnosc0_.PLATNOSC_NR as PLATNOS18_90_, platnosc0_.PLATNOSC_NUMER_KARTY as PLATNOS19_90_, platnosc0_.PLATNOSC_OPIS as PLATNOS20_90_, platnosc0_.PLATNOSC_PREFIX as PLATNOS21_90_, platnosc0_.PLATNOSC_RODZAJ as PLATNOS22_90_, platnosc0_.PLATNOSC_RODZAJ_KARTY_ID as PLATNOS23_90_, platnosc0_.PLATNOSC_STATUS as PLATNOS24_90_, platnosc0_.PLATNOSC_STWORZ_ZALICZKE as PLATNOS25_90_, platnosc0_.PLATNOSC_USED as PLATNOS26_90_, platnosc0_.PLATNOSC_Z_PLATNOSC_ID as PLATNOS27_90_, platnosc0_.PLATONLINE_ID as PLATONL28_90_, platnosc0_.POKOJ_ID as POKOJ_I29_90_, platnosc0_.RACHOTW_ID as RACHOTW30_90_, platnosc0_.REZERWACJA_ID as REZERWA31_90_, platnosc0_.WALUTA_ID as WALUTA_32_90_, platnosc0_.ZALICZKA_ID as ZALICZK33_90_, platnosc0_.ZMIANA_ID as ZMIANA_34_90_ from PLATNOSC platnosc0_ where platnosc0_.PLATNOSC_ID=?
2019-10-10 17:29:46 - Initiating transaction commit
2019-10-10 17:29:46 - Committing JPA transaction on EntityManager [SessionImpl(PersistenceContext[entityKeys=[EntityKey[ekoncept.entity.Platnosc#59905], EntityKey[ekoncept.entity.Platnosc#59858], EntityKey[ekoncept.entity.Faktura#141935], EntityKey[ekoncept.entity.Platnosc#59903], EntityKey[ekoncept.entity.Platnosc#59904], EntityKey[ekoncept.entity.Stale#101]],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])]
2019-10-10 17:29:46 - Not closing pre-bound JPA EntityManager after transaction
2019-10-10 17:29:46 - Found thread-bound EntityManager [SessionImpl(PersistenceContext[entityKeys=[EntityKey[ekoncept.entity.Platnosc#59905], EntityKey[ekoncept.entity.Platnosc#59858], EntityKey[ekoncept.entity.Faktura#141935], EntityKey[ekoncept.entity.Platnosc#59903], EntityKey[ekoncept.entity.Platnosc#59904], EntityKey[ekoncept.entity.Stale#101]],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])] for JPA transaction
2019-10-10 17:29:46 - Creating new transaction with name [ekoncept.service.PlatnoscServiceImpl.getRodzajTextForPlatnoscRodzaj]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2019-10-10 17:29:46 - Exposing JPA transaction as JDBC transaction [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@5cc07ca4]
2019-10-10 17:29:46 - Found thread-bound EntityManager [SessionImpl(PersistenceContext[entityKeys=[EntityKey[ekoncept.entity.Platnosc#59905], EntityKey[ekoncept.entity.Platnosc#59858], EntityKey[ekoncept.entity.Faktura#141935], EntityKey[ekoncept.entity.Platnosc#59903], EntityKey[ekoncept.entity.Platnosc#59904], EntityKey[ekoncept.entity.Stale#101]],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])] for JPA transaction
2019-10-10 17:29:46 - Participating in existing transaction
2019-10-10 17:29:46 - select stale0_.STALE_ID as STALE_ID1_134_0_, stale0_.STALE_CENTRUM_PRZYCH as STALE_CE2_134_0_, stale0_.STALE_KOD_SYSTEMU as STALE_KO3_134_0_, stale0_.STALE_KONTOKSIEGOWE_ID as STALE_KO4_134_0_, stale0_.STALE_NAZWA as STALE_NA5_134_0_, stale0_.STALE_RODZAJ_ID as STALE_RO6_134_0_, stale0_.STALE_WARTOSC as STALE_WA7_134_0_, stale0_.STALE_WARTOSC2 as STALE_WA8_134_0_, stale0_.STALE_WARTOSC3 as STALE_WA9_134_0_, stale0_.STALE_WARTOSC_EN as STALE_W10_134_0_, stale0_.STALE_WARTOSC_FLOAT as STALE_W11_134_0_, stale0_.STALE_WARTOSC_INT as STALE_W12_134_0_, stale0_.STALE_WARTOSC_INT2 as STALE_W13_134_0_, stale0_.STALE_WIDOCZNOSC as STALE_W14_134_0_ from STALE stale0_ where stale0_.STALE_ID=?
2019-10-10 17:29:46 - Initiating transaction commit
2019-10-10 17:29:46 - Committing JPA transaction on EntityManager [SessionImpl(PersistenceContext[entityKeys=[EntityKey[ekoncept.entity.Stale#402], EntityKey[ekoncept.entity.Stale#101], EntityKey[ekoncept.entity.Platnosc#59905], EntityKey[ekoncept.entity.Platnosc#59858], EntityKey[ekoncept.entity.Faktura#141935], EntityKey[ekoncept.entity.Platnosc#59903], EntityKey[ekoncept.entity.Platnosc#59904]],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])]
2019-10-10 17:29:46 - Not closing pre-bound JPA EntityManager after transaction
2019-10-10 17:29:46 - Found thread-bound EntityManager [SessionImpl(PersistenceContext[entityKeys=[EntityKey[ekoncept.entity.Stale#402], EntityKey[ekoncept.entity.Stale#101], EntityKey[ekoncept.entity.Platnosc#59905], EntityKey[ekoncept.entity.Platnosc#59858], EntityKey[ekoncept.entity.Faktura#141935], EntityKey[ekoncept.entity.Platnosc#59903], EntityKey[ekoncept.entity.Platnosc#59904]],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])] for JPA transaction
2019-10-10 17:29:46 - Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.findById]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2019-10-10 17:29:46 - Exposing JPA transaction as JDBC transaction [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@2c0c9b9d]
2019-10-10 17:29:46 - select platnosc0_.PLATNOSC_ID as PLATNOSC1_90_, platnosc0_.BANK_ID as BANK_ID2_90_, platnosc0_.EMPLOYEE_ID as EMPLOYEE3_90_, platnosc0_.FAKTURA_ID as FAKTURA_4_90_, platnosc0_.FAKTURA_ID1 as FAKTURA_5_90_, platnosc0_.FIRMA_ID as FIRMA_ID6_90_, platnosc0_.GRUPA_ID as GRUPA_ID7_90_, platnosc0_.KASA_ID as KASA_ID8_90_, platnosc0_.MELDUNEK_ID as MELDUNEK9_90_, platnosc0_.OSOBA_ID as OSOBA_I10_90_, platnosc0_.PLATNOSC_DATA as PLATNOS11_90_, platnosc0_.PLATNOSC_DATA_KARTY as PLATNOS12_90_, platnosc0_.PLATNOSC_DEKRET_ID as PLATNOS13_90_, platnosc0_.PLATNOSC_FK_NR as PLATNOS14_90_, platnosc0_.PLATNOSC_FORPLA as PLATNOS15_90_, platnosc0_.PLATNOSC_KOD_SYSTEMU as PLATNOS16_90_, platnosc0_.PLATNOSC_KWOTA as PLATNOS17_90_, platnosc0_.PLATNOSC_NR as PLATNOS18_90_, platnosc0_.PLATNOSC_NUMER_KARTY as PLATNOS19_90_, platnosc0_.PLATNOSC_OPIS as PLATNOS20_90_, platnosc0_.PLATNOSC_PREFIX as PLATNOS21_90_, platnosc0_.PLATNOSC_RODZAJ as PLATNOS22_90_, platnosc0_.PLATNOSC_RODZAJ_KARTY_ID as PLATNOS23_90_, platnosc0_.PLATNOSC_STATUS as PLATNOS24_90_, platnosc0_.PLATNOSC_STWORZ_ZALICZKE as PLATNOS25_90_, platnosc0_.PLATNOSC_USED as PLATNOS26_90_, platnosc0_.PLATNOSC_Z_PLATNOSC_ID as PLATNOS27_90_, platnosc0_.PLATONLINE_ID as PLATONL28_90_, platnosc0_.POKOJ_ID as POKOJ_I29_90_, platnosc0_.RACHOTW_ID as RACHOTW30_90_, platnosc0_.REZERWACJA_ID as REZERWA31_90_, platnosc0_.WALUTA_ID as WALUTA_32_90_, platnosc0_.ZALICZKA_ID as ZALICZK33_90_, platnosc0_.ZMIANA_ID as ZMIANA_34_90_ from PLATNOSC platnosc0_ where platnosc0_.PLATNOSC_ID=?
2019-10-10 17:29:46 - Initiating transaction commit
2019-10-10 17:29:46 - Committing JPA transaction on EntityManager [SessionImpl(PersistenceContext[entityKeys=[EntityKey[ekoncept.entity.Stale#402], EntityKey[ekoncept.entity.Stale#101], EntityKey[ekoncept.entity.Platnosc#59905], EntityKey[ekoncept.entity.Platnosc#59858], EntityKey[ekoncept.entity.Faktura#141935], EntityKey[ekoncept.entity.Platnosc#59903], EntityKey[ekoncept.entity.Platnosc#59904]],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])]
2019-10-10 17:29:46 - Not closing pre-bound JPA EntityManager after transaction
2019-10-10 17:29:46 - Found thread-bound EntityManager [SessionImpl(PersistenceContext[entityKeys=[EntityKey[ekoncept.entity.Stale#402], EntityKey[ekoncept.entity.Stale#101], EntityKey[ekoncept.entity.Platnosc#59905], EntityKey[ekoncept.entity.Platnosc#59858], EntityKey[ekoncept.entity.Faktura#141935], EntityKey[ekoncept.entity.Platnosc#59903], EntityKey[ekoncept.entity.Platnosc#59904]],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])] for JPA transaction
2019-10-10 17:29:46 - Creating new transaction with name [ekoncept.service.PlatnoscServiceImpl.getRodzajTextForPlatnoscRodzaj]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2019-10-10 17:29:46 - Exposing JPA transaction as JDBC transaction [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@7a494edf]
2019-10-10 17:29:46 - Found thread-bound EntityManager [SessionImpl(PersistenceContext[entityKeys=[EntityKey[ekoncept.entity.Stale#402], EntityKey[ekoncept.entity.Stale#101], EntityKey[ekoncept.entity.Platnosc#59905], EntityKey[ekoncept.entity.Platnosc#59858], EntityKey[ekoncept.entity.Faktura#141935], EntityKey[ekoncept.entity.Platnosc#59903], EntityKey[ekoncept.entity.Platnosc#59904]],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])] for JPA transaction
2019-10-10 17:29:46 - Participating in existing transaction
2019-10-10 17:29:46 - select stale0_.STALE_ID as STALE_ID1_134_0_, stale0_.STALE_CENTRUM_PRZYCH as STALE_CE2_134_0_, stale0_.STALE_KOD_SYSTEMU as STALE_KO3_134_0_, stale0_.STALE_KONTOKSIEGOWE_ID as STALE_KO4_134_0_, stale0_.STALE_NAZWA as STALE_NA5_134_0_, stale0_.STALE_RODZAJ_ID as STALE_RO6_134_0_, stale0_.STALE_WARTOSC as STALE_WA7_134_0_, stale0_.STALE_WARTOSC2 as STALE_WA8_134_0_, stale0_.STALE_WARTOSC3 as STALE_WA9_134_0_, stale0_.STALE_WARTOSC_EN as STALE_W10_134_0_, stale0_.STALE_WARTOSC_FLOAT as STALE_W11_134_0_, stale0_.STALE_WARTOSC_INT as STALE_W12_134_0_, stale0_.STALE_WARTOSC_INT2 as STALE_W13_134_0_, stale0_.STALE_WIDOCZNOSC as STALE_W14_134_0_ from STALE stale0_ where stale0_.STALE_ID=?
2019-10-10 17:29:46 - Initiating transaction commit
2019-10-10 17:29:46 - Committing JPA transaction on EntityManager [SessionImpl(PersistenceContext[entityKeys=[EntityKey[ekoncept.entity.Stale#402], EntityKey[ekoncept.entity.Stale#101], EntityKey[ekoncept.entity.Platnosc#59905], EntityKey[ekoncept.entity.Platnosc#59858], EntityKey[ekoncept.entity.Faktura#141935], EntityKey[ekoncept.entity.Platnosc#59903], EntityKey[ekoncept.entity.Platnosc#59904], EntityKey[ekoncept.entity.Stale#401]],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])]
2019-10-10 17:29:46 - Not closing pre-bound JPA EntityManager after transaction

为什么 Hibernate 看不到字段 platnoscNr 的值?

最佳答案

保存后刷新实体。 See the link for refresh

关于java - Hibernate 使用 findOne 和 findById 无法看到数据库中更新后触发器对记录所做的更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58326568/

相关文章:

java - java 中列表中表达式的最大数量为 1000

Java正则表达式格式字符串

java - 什么是 NullPointerException,我该如何解决?

java - 我如何在Spring Boot中使用Mailgun接收电子邮件

java - IntelliJ 如何删除类里面丢失的包

java - Jpa Hibernate Spring Jpa 存储库查询希伯来语值

java - 为没有 Hibernate Annotations 的 PostgreSQL 文本类型更正 JPA Annotation

java - 在 fragment 中的 ConfigurationChange 之后,onClickListener 无法(正确)工作

java - 如果应用程序在后台,如何使用 fcm 获取从服务器发送的数据?

java - 使用SimpleBrokerMessageHandler时的通信关系 - STOMP Spring