Reputation: 63
The following query throws the exception:
Query query = session.createQuery("from Associate as a order by a.username asc");
associates = query.list();
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [ca.mypkg.model.Associate#0]
If I create an entry in the database with id
of 0
it works just fine. I don't really get it because I'm just trying to load all the entries in the db not just a specific one.
Similar questions I've found have been concerned with trying to load an object with a given ID
I'm doing no such thing.
Associate class:
@Table(name = "user")
@XmlRootElement(name = "associate")
public class Associate implements Serializable {
private String username;
private String password;
private String firstName;
private String lastName;
private String userType;
private int id;
private String email;
private String isActive;
private Department dept;
private String lastUpdated;
private String associate_type;
// ...
@Id
@GeneratedValue
public int getId() {
return id;
}
@OneToOne
@JoinColumn(name = "dept")
public Department getDept() {
return dept;
}
Upvotes: 2
Views: 1480
Reputation: 124
From my experience this type of error message usually means it does not find joined entity by mentioned id, and not the entity requested in the query (Associate, in your case). My guess is that Associate class contains a join entity which has primitive type primary key.
Upvotes: 6