gpt4 book ai didi

java - Java Spring 的 JpaRepository : No property findbyUser found for type User

转载 作者:行者123 更新时间:2023-12-01 09:00:27 25 4
gpt4 key购买 nike

我有一个 User 类实体:

@Entity
@Table(name = "USERS")
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@json-id")
public class User extends AbstractEntity {

@Id
@SequenceGenerator(name = "USERS_SEQ", sequenceName = "S_USER_ACCOUNT")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "USERS_SEQ")
@Column(name = "USER_ID", precision = 22, scale = 0)
private Long userId;

@Column(name = "ID_TYPE")
private String idType;

@Column(name = "COUNTRY_CODE", length = 3, nullable = false)
@NotBlank
private String countryCode;
}
}

和类 UserRepository 扩展自 JpaRepository

@Repository
public interface UserRepository extends JpaRepository<User, Long> {

Page<User> findbyUser(User users, Pageable pageable);


}

构建并编译源代码时,我收到一条错误消息:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property findbyUser found for type User!

我想用实体中的任何字段搜索用户。可以请您谈谈您的想法吗?

最佳答案

谢谢大家。我刚刚研究了这个答案的解决方案。效果很好。

Example<User> example = Example.of(user); 
Page<User> pageResult = usersRepository.findAll(example, pageable);

关于java - Java Spring 的 JpaRepository : No property findbyUser found for type User,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41715774/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com