2

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;
}
3
  • 1
    Looks like problem with the order by clause, please post your Assiociate Entity. Commented Jan 18, 2013 at 15:19
  • Looks you don't have the username attribute in the Associate entity class. As @Atropo mentioned, please provide this class. Commented Jan 18, 2013 at 15:29
  • the same exception is thrown even without the order by clause Commented Jan 18, 2013 at 16:27

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

1 Comment

You're exactly right. It seems in the department table the department manager user id was set to 0 which doesn't exist in the user table. The exception is a bit misleading. THanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.