我有一个 APIObjects 列表List<APIObjects> apiObjectList作为我的 API 的输入(通过 HTTP-Post),我需要检查这个对象中的所有参数是否存在于我的数据库中DatabaseObject.java@Data@Builder@NoArgsConstructor@AllArgsConstructor@Entity@Table(name = "my_table")public class DatabaseObject { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) Long id; @Column(name = "name") String name; @Column(name = "group_id") String groupId; @Column(name = "artifact_id") String artifactId; @Column(name = "version") String version; }APIObject.java@Data@NoArgsConstructor@AllArgsConstructor@Builderpublic class APIObject{ private String groupId; private String artifactId; private String version;}在我Repository Interface我有这样的方法List<DatabaseObject> findByGroupIdAndArtifactIdAndVersionIn (List<APIobject> apiList);但我得到这个例外Caused by: java.lang.IllegalArgumentException: No parameter available for part artifactId SIMPLE_PROPERTY (1): [Is, Equals].如何为此编写Spring-data-JPA方法?所有三个参数都应该匹配(groupid, artifactid and version)
2 回答
有只小跳蛙
TA贡献1824条经验 获得超8个赞
尝试使用Query by Example技术。在您的情况下,解决方案可能如下所示:
DatabaseObject dbObject = new DatabaseObject(apiObject.getGroupId(), ...);
Iterable<DatabaseObject> dbObjects = DatabaseObjectRepository.findAll(Example.of(dbObject));
添加回答
举报
0/150
提交
取消