【发布时间】:2019-12-17 16:44:03
【问题描述】:
问题是我的 UserRepository 扩展 JpaRepository 时使用 @RepositoryRestResource 时出现异常。
原因是findById默认只接受Long或Int类型,即使我有
@Id String id; 而不是@Id Int id 在我的实体定义中。
我已经尝试搜索 StackOverflow 和 Google,但没有找到任何解决方案。
错误信息如下:
"Failed to convert from type [java.lang.String] to type [java.lang.Integer] for value '3175433272470683'; nested exception is java.lang.NumberFormatException: For input string: \"3175433272470683\""
我想让它与 a 一起工作
@Id String id;
有什么建议吗?
非常感谢您的进步。很荣幸在这里提问。
实体类:
@Entity // This tells Hibernate to make a table out of this class
@Table(name = "users")
public class XmppUser {
@Id
private java.lang.String username;
private String password;
private String serverkey;
private String salt;
private int iterationcount;
private Date created_at;
// @Formula("ST_ASTEXT(coordinates)")
// @Column(columnDefinition = "geometry")
// private Point coordinates;
// private Point coordinates;
private String full_name;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "username", nullable = true)
private XmppLast xmppLast;
【问题讨论】:
-
能否贴出实体类代码?
-
刚刚发布了一个实体类
标签: java spring hibernate spring-data-jpa spring-hateoas