ClientApp, Java:
Code:
@Entity
@Table(name = "ClientApp", uniqueConstraints = @UniqueConstraint(columnNames = "appID"))
Query methods, java (note that APP_ID actually represents appId:
Code:
public List<ClientApp> findByProperty(String propertyName, Object value) {
log.debug("finding ClientApp instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from ClientApp as model where model."
+ propertyName + "= ?";
Query queryObject = getSession().createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List<ClientApp> findByAppId(Object appId) {
return findByProperty(APP_ID, appId);
}
Relevant parts of the trace:
Code:
Sep 06 02:24:01 (ErrorCounter.java:68) DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
Sep 06 02:24:01 (HqlSqlBaseWalker.java:111) DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - select << begin [level=1, statement=select]
Sep 06 02:24:01 (ClientAppDAO.java:108) ERROR com.medialets.orm.hib.ClientAppDAO - find by property name failed
org.hibernate.hql.ast.QuerySyntaxException: ClientApp is not mapped [from ClientApp as model where model.appId= ?]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158)
every possible thread I've found on this have all been due to mismatch between table and class names, or using a table name instead of a class name, or mispelling, or something that would cause hibernate to not grab the mapping. But my mapping is definitely correct: table is ClientApp and Class is ClientApp, and the query string uses ClientApp. The other solution was making sure you're using javax.persistence.Entity and not the hibernate...Entity package, which I'm also doing.
What else could cause this? It's brain dead simple query...
Thanks, Bill