Home » Support » Forum » Entity Type is not found (error 301) in Query

Entity Type is not found (error 301) in Query


Overall test OpenJPA, HibernateJAP, EclipseLink and ObjectDB. No Problem with OpenJPA, HibernateJAP, EclipseLink

For ObjectDB there is one query in following method, where the full qualified class name is necessary. See method code - red part

Otherwise an error will occure.

[ObjectDB 2.4.7_17] select u from  ==> User <==  u where u.email = :email
Type User is not found (error 301)
(position 14) at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:695)
at at.sciencesoft.db.jpa.DAOjpa.query(DAOjpa.java:326)
at at.sciencesoft.user.User.checkConstraints(User.java:11

This behaviour is very strange, because in the same method - other workflow - the query works with the simple class name. Breaking down the code for simple example would be little compilcated. Have you any idea, what is going wrong?


public void checkConstraints(DAOiface dao, UpdateMap update) throws Exception {
    List<Base> list = null;

    HashMap<String, Object> map = new HashMap<String, Object>();
    if (update == null) {
        map.put("email", getEmail());
        list = (List<Base>) dao.query(
            "select u from " + User.class.getCanonicalName()
           + " u where u.email = :email", map);
    } else {
        Update m = update.get(User.Fields.email);
        if (m != null) {
            map.put("histId", getHistId());
            map.put("email", m.getString());
            list = (List<Base>) dao.query(
                "select u from User u where u.email = :email and u.histId <> :histId",
    if (list != null && list.size() > 0) {
        throw new Exception(
            "User.checkConstraints(): Property email isn't unique!");




This could happen if the entity class is not in the database yet (no instances of that class have been persisted yet), and a persistence unit is not defined.

If this seems to be the cause, either define a persistence unit or introduce the class to ObjectDB before the query, for example by:



ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)


Thanks for the fast response - fast JPA impl and fast support!  You are right, the first query is invoked when the database is empty - no persisted entities.

Explict call of this method:


before the first query failed - same problem. BUT according your link - creating explicit a persistence.xml file for objectDB fixes the problem. In my case the fix was simple, for all other JPA impl this files was created, but not for ObjectDB.

with best regards


Post Reply

To post a reply and/or subscribe to update notifications - please login