Reputation: 1578
I am new in JPA so I made a small application. And in my app, I have a @Query like:
@Query("select a from T_RBM_OPSCREENS_APPLICATIONS a, T_SCR_APPS_OPS_ROLES b where a.id=b.app_id and b.role_id=?1")
When application starts running, it gives the error:
Caused By: org.hibernate.hql.internal.ast.QuerySyntaxException: T_RBM_OPSCREENS_APPLICATIONS is not mapped [select a from T_RBM_OPSCREENS_APPLICATIONS a, T_SCR_APPS_OPS_ROLES b where a.id=b.app_id and b.role_id=?1] at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:180) at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110) at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:93) at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:324) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3270) Truncated. see log file for complete stacktrace
But I did the Mapping like:
@Entity
@Table(name = "T_RBM_OPSCREENS_APPLICATIONS", schema = "RBMCORE")
public class Application implements Serializable{
@Id
@Column(name = "id")
private int id;
@Column(name = "s_appname", unique = true, nullable = false)
private String name;
.
.
.
What am I missing?
Thanks
Upvotes: 1
Views: 956
Reputation: 692231
JPQL/HQL queries use entities and their persistent fields/properties/associations. They don't use tables and columns.
Your query should be something like:
select a from Application a inner join a.roles role where role.id = ?1
Read the documentation.
Upvotes: 4