I don't know what's up. My jpa mapping seems fine, yet I get this error :
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
User class:
@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;}
}
GPSCoordinates class:
@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;}
}
Change
@JoinColumn(name="user")
to
@JoinColumn(name="column_name_of_user_id")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With