greenrobot/greenDAO · error · DaoException

Property '

Error message

Property '

What it means

WhereCollector.checkProperty() verifies that a Property used in a where() condition belongs to the DAO (table) the query is built for. If the property is from another entity's Properties class, a DaoException 'Property ... is not part of <dao>' is thrown. This catches cross-entity condition mistakes at query-build time.

Solutions

  1. Use the Properties class matching the DAO: userDao.queryBuilder().where(UserDao.Properties.X...).
  2. For conditions on a joined table, put them on the join builder: .join(DeptDao.class, ...).where(DeptDao.Properties.Name.eq(...)).
  3. Check imports — static imports of the wrong Properties class are the usual culprit.

Example fix

// before
userDao.queryBuilder().where(DeptDao.Properties.Name.eq("sales"));
// after
userDao.queryBuilder()
  .join(DeptDao.class, UserDao.Properties.DeptId)
  .where(DeptDao.Properties.Name.eq("sales"));
Defensive patterns

Strategy: type-guard

Validate before calling

// at call sites, import the matching Properties class explicitly
import org.greenrobot.greendao.sample.UserDao.Properties;

Type guard

boolean belongsToDao(Property p, AbstractDao<?, ?> dao) {
  for (Property q : dao.getProperties()) if (q == p) return true;
  return false;
}

Try / catch

try { qb.where(prop.eq(v)); } catch (DaoException e) { throw new IllegalArgumentException("use the Properties class of " + e.getMessage()); }

Prevention

When it happens

Trigger: Passing a Property from a different entity's Properties class into where() of another DAO's queryBuilder — e.g. userDao.queryBuilder().where(DeptDao.Properties.Name.eq("x")).

Common situations: Copy-pasting query code between entities, or mixing Properties classes when building joins without putting the foreign condition on the joined table's section of the builder.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of greenrobot/greenDAO@0bbb338e17 (2026-09-08). Data as JSON: /api/errors/6d31d726914ec9bf. Report an issue: GitHub.

Appendix: source

Thrown at DaoCore/src/main/java/org/greenrobot/greendao/query/WhereCollector.java:88

    void checkCondition(WhereCondition whereCondition) {
        if (whereCondition instanceof WhereCondition.PropertyCondition) {
            checkProperty(((WhereCondition.PropertyCondition) whereCondition).property);
        }
    }

    void checkProperty(Property property) {
        if (dao != null) {
            Property[] properties = dao.getProperties();
            boolean found = false;
            for (Property property2 : properties) {
                if (property == property2) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                throw new DaoException("Property '" + property.name + "' is not part of " + dao);
            }
        }
    }

    void appendWhereClause(StringBuilder builder, String tablePrefixOrNull, List<Object> values) {
        ListIterator<WhereCondition> iter = whereConditions.listIterator();
        while (iter.hasNext()) {
            if (iter.hasPrevious()) {
                builder.append(" AND ");
            }
            WhereCondition condition = iter.next();
            condition.appendTo(builder, tablePrefixOrNull);
            condition.appendValuesTo(values);
        }
    }

    boolean isEmpty() {
        return whereConditions.isEmpty();

View on GitHub (pinned to 0bbb338e17)