简体   繁体   English

休眠PropertyNotFoundException

[英]hibernate PropertyNotFoundException

I already found some information about this exception but mine is very strange. 我已经找到了有关此异常的一些信息,但是我的情况很奇怪。

Caused by: org.hibernate.PropertyNotFoundException: 
Could not find a setter for property empty in class java.util.List

There is no information where is the failure. 没有任何信息在哪里失败。 I use List in my entities but I don't understand where is the failure. 我在实体中使用列表,但我不知道失败在哪里。

Hibernate is trying to persist a List object and telling you there is no setEmpty(boolean empty) method on List. Hibernate试图持久保存List对象,并告诉您List上没有setEmpty(boolean empty)方法。

This is caused by a configuration problem trying to create a relationship between two entities. 这是由于试图在两个实体之间建立关系的配置问题引起的。

Update: 更新:

setEmpty is not needed. 不需要setEmpty。 The way you've configured your collection on the hibernate entity is confusing Hibernate into trying to persist a List instead of creating a relationship between rows in two tables. 您在hibernate实体上配置集合的方式使Hibernate难以保存列表,而不是在两个表中的行之间创建关系。 You need to correctly configure the one-to-many relationship in question. 您需要正确配置有问题的一对多关系。

I got it. 我知道了。 I use this embedded collection in a super class and override its getter setter in subclass. 我在超类中使用此嵌入式集合,并在子类中覆盖其getter setter。 The problem was, i had @ElementCollection annotation just in subclass. 问题是,我只是在子类中有@ElementCollection批注。 When i wrote it to superclass, the problem was solved. 当我将它写给超类时,问题就解决了。 thanks for your responses. 感谢您的回复。

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

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