Announcement Announcement Module
Collapse
No announcement yet.
org.hibernate.hql.ast.QuerySyntaxException: CSUser is not mapped Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • org.hibernate.hql.ast.QuerySyntaxException: CSUser is not mapped

    Hi All,
    I am getting this weird error with my JPA query. Looks like everything is mapped fine.
    here is the Entity classes and all that.
    I have these three tables in the database

    CS_USER, CS_ROLE and CS_USER_ROLE

    Code:
    @Entity
    @Table(name = "CS_USER")
    public class CSUser implements Serializable {
          private static final long serialVersionUID = 7150233907585725854L;
    
          @Id
    
          @Column(name = "user_id")
    
          private Integer userId;
    
          @ManyToMany(cascade = {CascadeType.ALL})
          @JoinTable(name = "CS_USER_ROLE", joinColumns = {@JoinColumn(name = "user_id")}, inverseJoinColumns = {@JoinColumn(name = "role_id")})
          private List<CSRole> csRoles = new ArrayList<CSRole>();
    Code:
    @Entity
    
    @Table(name = "CS_ROLE")
    
    public class CSRole implements Serializable {
    
          private static final long serialVersionUID = 7150233907585725853L;
    
          @Id
    
          @Column(name = "role_id")
    
          private Integer roleId;
    
           .......
    
          @ManyToMany(mappedBy = "csRoles")
    
          private List<CSUser> csUsers = new ArrayList<CSUser>();
    This is what I am doing to run the query
    Code:
    String hql_fetchUsers = "select distinct user from CSUser user " +
                                "join fetch user.csRoles role " +
                                "where role.roleId = :roleId";
    
    Query result = em.createQuery(hql_fetchUsers );
    Could someone please let me know why I am getting this error.

    I am using javax.persistenece.Entity

    Thanks a lot in Advance.

    Rajesh
Working...
X