title: How should i solve Exception "Unable to resolve path" while executing a query in hibernate?
body: <p>I am trying to test a simple application that uses hibernate and annotations.I have the follwing database tables with the following foreign key constraints.</p>
  
  <pre><code>create table user_info 
  (
  mobile_number varchar(16) primary key, 
  gender char(1),
  language varchar(4))
  
  
  create table user_order_info
  (order_id integer(16) not null primary key auto_increment,   
  mobile_number varchar(16) not null,
  location_name varchar(32) not null, 
  foreign key(mobile_number) references user_info(mobile_number),
  
  create table user_queue_order_info
  (queue_id integer(16) not null primary key auto_increment,
  order_id integer(16),   
  mobile_number varchar(16) not null,  
  order_value integer(8) not null,   
  foreign key(mobile_number) references user_info(mobile_number),
  foreign key(order_id) references user_order_info(order_id) on delete cascade)
  </code></pre>
  
  <p>And the respective entity table of the above table are as follows:</p>
  
  <pre><code>@Entity
  @Table(name = "user_info")
  public class UserInfo implements Serializable {         
  private String mobileNumber;    
  private char gender;
  private String language;
      //getters and setters and constructors
  }
  
  
  @Entity
  @Table(name = "user_order_info")
  
  public UserOrderInfo implements Serializable {  
  private long orderId;
  private String locationName;        
  private UserInfo userInfo;
      //getters and setters and constructors
  }
  
  
  @Entity
  @Table(name = "user_queue_order_info")
  
  public class UserQueueOrderInfo implements Serializable {   
  
  private long queueId;   
  private int orderValue; 
  private UserInfo userInfo;
  private UserOrderInfo userOrderinfo;
      //getters and setters , constructors
  </code></pre>
  
  <p>The problem is  whenI try to use UserOrderInfoDao to access the database by using the following method, exception is coming.</p>
  
  <pre><code>public UserOrderInfo UserOrderInfoByMobileNumber(String mobileNumber ) {
  List&lt;UserOrderInfo&gt; userOrderInfoList =    sessionFactory.getCurrentSession().createQuery("from UserOrderInfo where userInfo.mobileNumber='"+mobileNumber+"'").list();
      if(!userOrderInfoList.isEmpty()){
          return userOrderInfoList.get(0);
      }
      return null;
  }
  </code></pre>
  
  <p>When i try to debug by tracing the exception,the exception coming is:</p>
  
  <blockquote>
    <p>Exception Unable to resolve path [userInfo.mobileNumber], unexpected token [userInfo]   [from com.appls.entity.UserOrderInfo where userInfo.mobileNumber='7770909090']</p>
  </blockquote>
  
  <p>why is this problem is coming?I am waiting for your valuble suggestions.</p>
  
  <p>And I have done the mappings in getters and setters in the following way:</p>
  
  <pre><code>@Id 
  @Column(name = "mobile_number")
  public String getMobileNumber() {
      return mobileNumber;
  }
  </code></pre>
  
  <p>Same for other fields also.</p>
  
  <p>Entity for User_info is </p>
  
  <pre><code>    private String mobileNumber;        
  private char gender;
  private String language;
  
  @Id 
  @Column(name = "mobile_number")
  public String getMobileNumber() {
      return mobileNumber;
  }
  public void setMobileNumber(String mobileNumber) {
      this.mobileNumber = mobileNumber;
  }
  
  @Column(name = "gender")
  public char getGender() {
      return gender;
  }
  public void setGender(char gender) {
      this.gender = gender;
  }
  
  @Column(name = "language")
  public String getLanguage() {
      return language;
  }
  public void setLanguage(String language) {
      this.language =language;
  }
  
  public UserInfo() {
      super();        
  }
  
  
  public UserInfo(String mobileNumber){
      super();
      this.mobileNumber = mobileNumber;
  }
  
  public UserInfo(String mobileNumber, char gender, String language) {
      super();
      this.mobileNumber =mobileNumber;
      this.gender = gender;
      this.language = language;
  
  }   
  
  @Override
  public String toString() {
  return "{\"mobileNumber\": \"" + this.mobileNumber
              + "\", \"gender\": \"" + this.gender
              + "\", \"language\": \"" + this.language }";
  }
  </code></pre>