简体   繁体   English

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

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

I am getting the below exception when i run the spring boot application. 当我运行spring boot应用程序时,出现以下异常。 But the same code works fine when we execute as a plain java. 但是当我们作为纯Java执行时,相同的代码也可以正常工作。

Exception: 例外:

at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.sample.model.TRSN_LOOKUP.emClntId at org.hibernate.property.access.spi.GetterMethodImpl.get(GetterMethodImpl.java:64) at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:230) at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4725) 在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)

This is for spring-boot standalone application running in windows 这适用于在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();

Continuation from my above comments: 从我上面的评论继续:

Just try with naming-strategy property which will help you to use a similar name. 只需尝试使用naming-strategy属性,它将帮助您使用类似的名称。

For example,: Spring will change entity name from TRSN_LOOKUP to tRSN_LOOKUP . 例如: Spring将实体名称从TRSN_LOOKUP更改为tRSN_LOOKUP So, please try adding one more property in hibernate. 因此,请尝试在休眠中再添加一个属性。

There are two types of strategy, you can use 2nd one: 策略有两种,您可以使用第二种策略:

1. org.hibernate.cfg.ImprovedNamingStrategy

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

which help you keep the same name in all DB fields. 这可以帮助您在所有数据库字段中保持相同的名称。

暂无
暂无

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

相关问题 休眠:org.hibernate.PropertyAccessException:IllegalArgumentException - Hibernate : org.hibernate.PropertyAccessException: IllegalArgumentException Hibernate Criteria - org.hibernate.PropertyAccessException:IllegalArgumentException - Hibernate Criteria - org.hibernate.PropertyAccessException: IllegalArgumentException org.hibernate.PropertyAccessException持续存在 - org.hibernate.PropertyAccessException on persist org.hibernate.PropertyAccessException:使用CGLIB设置异常的属性值 - org.hibernate.PropertyAccessException: exception setting property value with CGLIB 嵌套的异常是org.hibernate.PropertyAccessException:无法设置字段值 - nested exception is org.hibernate.PropertyAccessException: Could not set field value 是什么导致org.hibernate.PropertyAccessException:setter中发生异常 - What cause org.hibernate.PropertyAccessException: Exception occurred inside setter 如何修复org.hibernate.PropertyAccessException:无法通过反射设置器设置字段值 - How to fix org.hibernate.PropertyAccessException: Could not set field value value by reflection setter of org.hibernate.PropertyAccessException-如何从数据库中获取空值? - org.hibernate.PropertyAccessException - How to get a null value out of database? jComboBox给出org.hibernate.PropertyAccessException错误 - jComboBox giving org.hibernate.PropertyAccessException error org.hibernate.PropertyAccessException:调用com.dms.model.Group.groupId的getter时发生了IllegalArgumentException - org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.dms.model.Group.groupId
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM