0

I am using the following bean class

package com.hibernatemappingfile;

import java.io.Serializable;

 import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;


@Entity
@Table(name="SKILL_SET")

public class SkillSet implements Serializable{

  @Id
  @Column(name="ID")
  @GeneratedValue(strategy=GenerationType.AUTO)
  private String id;
  public String getId() {
        return id;
   }
   public void setId(String id) {
      this.id = id;
   }

   @Column(name="COMPUTER_SKILLS")
   private String computer_skills;
   @Column(name="TRAININGS_ATTENDED")
   private String trainings_attended;

   @OneToOne(cascade = CascadeType.ALL)
   @JoinColumn(name = "USER_ID")
   private EmployeeMaster employee;


   public EmployeeMaster getEmployee() {
        return employee;
   }
   public void setEmployee(EmployeeMaster employee) {
        this.employee = employee;
   }
   public String getComputer_skills() {
        return computer_skills;
   }
   public void setComputer_skills(String computer_skills) {
        this.computer_skills = computer_skills;
   }
   public String getTrainings_attended() {
        return trainings_attended;
   }
   public void setTrainings_attended(String trainings_attended) {
        this.trainings_attended = trainings_attended;
   }


}

and my hql query is

SELECT t1.trainings_attended,t2.workingstatus 
FROM SkillSet t1, EmployeeStatus t2,EmployeeMaster em 
WHERE t1.trainings_attended=:trainings_attended AND t1.USER_ID = t2.USER_ID

but i am getting the following exception

SEVERE: Servlet.service() for servlet [sdnext] in context with path [/sdnext] threw exception [Request processing failed; nested exception is org.hibernate.QueryException: could not resolve property: USER_ID of: com.vrnda.hibernatemappingfile.SkillSet [SELECT t1.trainings_attended,t2.workingstatus FROM com.vrnda.hibernatemappingfile.SkillSet t1, com.vrnda.hibernatemappingfile.EmployeeStatus t2,com.vrnda.hibernatemappingfile.EmployeeMaster em WHERE t1.trainings_attended=:trainings_attended AND t1.USER_ID = t2.USER_ID]] with root cause
org.hibernate.QueryException: could not resolve property: USER_ID of: com.vrnda.hibernatemappingfile.SkillSet [SELECT t1.trainings_attended,t2.workingstatus FROM com.vrnda.hibernatemappingfile.SkillSet t1, com.vrnda.hibernatemappingfile.EmployeeStatus t2,com.vrnda.hibernatemappingfile.EmployeeMaster em WHERE t1.trainings_attended=:trainings_attended AND t1.USER_ID = t2.USER_ID]

How to get the user_id of skillset table in select statement.i have tried with t1.em.USER_ID but not working.

1 Answer 1

1

try JOIN t1.employee employee and then you will have access to employee.user_id

Sign up to request clarification or add additional context in comments.

2 Comments

user_id is a database column name. And it is not need to use a join to access an id property (but unclear, does @bajky mean emloyee.id?)
with employee.user_id i mean primary key of employeeMaster.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.