gpt4 book ai didi

hibernate - 通过持久属性的反射访问字段 xxx 时出错

转载 作者:行者123 更新时间:2023-12-03 14:11:42 25 4
gpt4 key购买 nike

我不知道怎么回事。我的 jpa 映射看起来不错,但我收到此错误:

Error accessing field [private main.java.entities.User main.java.entities.GPSCoordinates.user] by reflection for persistent property [main.java.entities.GPSCoordinates#user] : main.java.entities.GPSCoordinates


Caused by: javax.persistence.PersistenceException: org.hibernate.property.access.spi.PropertyAccessException: Error accessing field [private main.java.entities.User main.java.entities.GPSCoordinates.user] by reflection for persistent property [main.java.entities.GPSCoordinates#user] : main.java.entities.GPSCoordinates@1
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1692)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602)
at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:560)
at main.java.lookup.UserServiceImp.findByUuid

用户类:
@Entity
@Table
@NamedQuery(name = "User.findByUuid", query = "SELECT u FROM User u WHERE u.uuid=:uuid")
public class User implements Serializable, PictureHolder {
//...
@OneToOne(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
private GPSCoordinates coordinates;

public GPSCoordinates getCoordinates() { return coordinates;}
public void setCoordinates(GPSCoordinates coordinates) {this.coordinates = coordinates;}
}

GPS坐标类:
@Entity
@Table(name="user_gps_coordinates")
public class GPSCoordinates implements Serializable{

@Id
@OneToOne
@JoinColumn(name="user")
private User user;

public User getUser() { return user; }
public void setUser(User user) {this.user = user;}
}

最佳答案

改变

@JoinColumn(name="user")


@JoinColumn(name="column_name_of_user_id")

关于hibernate - 通过持久属性的反射访问字段 xxx 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38162262/

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