我有实体
@Entity
@Table(name = "messages")
public class Message {
...
@Column(name = "isVisibleForSender")
private boolean isVisibleForSender;
}
和Spring Data存储库
@Repository
@Transactional
public interface MessageCRUDRepository extends JpaRepository<Message, Long> {
...
public boolean getVisibleForRecipient(boolean isVisibleForRecipient);
}
编译时,程序会抛出异常引起:org.springframework.data.mapping.PropertyReferenceException:找不到类型Message的属性getIsVisibleForRecipient
答案 0 :(得分:0)
看到您的评论后,您的方法名称错误:
@Entity
@Table(name = "messages")
public class Message {
@Column(name = "isVisibleForRecipient")
private boolean visibleForRecipient;
}
对于回购:
interface MessageCRUDRepository extends JpaRepository<Message, Long> {
List<Message> findByVisibleForRecipient(Boolean bool);
}
确保消息对象
中的visibleForRecipient字段具有getter和setter