繁体   English   中英

如何修复Spring Boot应用程序中的org.hibernate.PropertyAccessException:IllegalArgumentException异常

[英]How to fix org.hibernate.PropertyAccessException: IllegalArgumentException exception in spring boot application

当我运行spring boot应用程序时,出现以下异常。 但是当我们作为纯Java执行时,相同的代码也可以正常工作。

例外:

在org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)上由以下原因引起:org.hibernate.PropertyAccessException:IllegalArgumentException发生在org.hibernate.property上调用com.sample.model.TRSN_LOOKUP.emClntId的getter。 org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:230)处的.access.spi.GetterMethodImpl.get(GetterMethodImpl.java:64)在org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java :4725)

这适用于在Windows中运行的spring-boot独立应用程序

 Session session = getSession();
if (!session.getTransaction().isActive() )
    session.beginTransaction();

    TRSN_LOOKUP trsnlookup = new TRSN_LOOKUP();             

        trsnlookup.setPrsnid(PrsnId);
        trsnlookup.setEmClntId(clientId);           

    session.save(trsnlookup);
    session.getTransaction().commit();

从我上面的评论继续:

只需尝试使用naming-strategy属性,它将帮助您使用类似的名称。

例如: Spring将实体名称从TRSN_LOOKUP更改为tRSN_LOOKUP 因此,请尝试在休眠中再添加一个属性。

策略有两种,您可以使用第二种策略:

1. org.hibernate.cfg.ImprovedNamingStrategy

2. org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

这可以帮助您在所有数据库字段中保持相同的名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM