[英]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.