![](/img/trans.png)
[英]Hibernate : 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.