Java 属性以值显示在hibernate跟踪日志中,但值未映射到对象属性

Java 属性以值显示在hibernate跟踪日志中,但值未映射到对象属性,java,hibernate,spring-data,Java,Hibernate,Spring Data,我有一个实体类,其中包含许多属性 这些属性由Hibernate在spring引导初始化期间通过Hibernate AnnotationBinder正确地发现,并且值正确地来源于我们的数据库,并通过Hibernate BasicExtractor正确地映射到对象 但是,在访问属性时,它们的值似乎来自过时的缓存版本。例如,它的值总是空的,而不是提取器日志中显示的值,我似乎不知道为什么。注意:我可以保存到该属性并使其正确持久,我只是无法从中读取 WHTFMain类 @Entity @Table(nam

我有一个实体类,其中包含许多属性

这些属性由Hibernate在spring引导初始化期间通过Hibernate AnnotationBinder正确地发现,并且值正确地来源于我们的数据库,并通过Hibernate BasicExtractor正确地映射到对象

但是,在访问属性时,它们的值似乎来自过时的缓存版本。例如,它的值总是空的,而不是提取器日志中显示的值,我似乎不知道为什么。注意:我可以保存到该属性并使其正确持久,我只是无法从中读取

WHTFMain类

@Entity
@Table(name = "whtf_main")
public class WHTFMain {
     ...
     @Column(nullable = true)
     private String netsuiteId;
     ....
     // getter/setter not shown
 }
注释活页夹日志:

[main] TRACE org.hibernate.cfg.AnnotationBinder - Processing annotations of com.xxx.modules.netsuite.customRecords.WHTFMain.netsuiteId 
[main] TRACE org.hibernate.engine.jdbc.env.internal.NormalizingIdentifierHelperImpl - Normalizing identifier quoting [netsuiteId] 
[main] TRACE org.hibernate.engine.jdbc.env.internal.NormalizingIdentifierHelperImpl - Normalizing identifier quoting [netsuiteId] 
[main] DEBUG org.hibernate.cfg.Ejb3Column - Binding column: Ejb3Column{table=org.hibernate.mapping.Table(whtf_main), mappingColumn=netsuite_id, insertable=true, updatable=true, unique=false} 
[main] DEBUG org.hibernate.cfg.annotations.PropertyBinder - MetadataSourceProcessor property netsuiteId with lazy=false 
[main] DEBUG org.hibernate.cfg.AbstractPropertyHolder - Attempting to locate auto-apply AttributeConverter for property [com.xxx.modules.netsuite.customRecords.WHTFMain:netsuiteId] 
[main] DEBUG org.hibernate.cfg.annotations.SimpleValueBinder - building SimpleValue for netsuiteId 
[main] TRACE org.hibernate.engine.jdbc.env.internal.NormalizingIdentifierHelperImpl - Normalizing identifier quoting [netsuiteId] 
[main] TRACE org.hibernate.engine.jdbc.env.internal.NormalizingIdentifierHelperImpl - Normalizing identifier quoting [netsuiteId] 
[main] TRACE org.hibernate.engine.jdbc.env.internal.NormalizingIdentifierHelperImpl - Normalizing identifier quoting [netsuiteId] 
[main] DEBUG org.hibernate.cfg.annotations.PropertyBinder - Building property netsuiteId 
[main] TRACE org.hibernate.cfg.annotations.PropertyBinder - Cascading netsuiteId with null 
基本提取器日志(503是正确的值)

查询:

public List<WHTFMain> findByMongoId(String mongoId) {
    return entityManager.createQuery("select w from WHTFMain w where mongoId = :mongoId", WHTFMain.class)
            .setParameter("mongoId",mongoId)
            .getResultList();
}

您的交易边界在哪里?您是否激活了日志记录以查看sql语句的事务处理和执行情况?@jenschauder感谢您的轻推-我从我的bean中删除了事务注释,现在该值正在按预期传播。你能解释一下为什么事务边界会导致这个问题持续存在吗?我本来不考虑这个问题,因为这个问题会在应用程序的多次运行中出现。我不知道实际发生了什么,因为我不知道您在哪个事务中做了什么/看到了什么。但当人们在9/10案例中看到与DBs/JPA不一致的数据时,这是事务/会话处理。@Jenschauder谢谢,我会记住这一点。我很感激
public List<WHTFMain> findByMongoId(String mongoId) {
    return entityManager.createQuery("select w from WHTFMain w where mongoId = :mongoId", WHTFMain.class)
            .setParameter("mongoId",mongoId)
            .getResultList();
}
List<WHTFMain> whtfMainList = whtfDAO.findByMongoId(whtfMain.getMongoId());
netsuiteId = null