title: HTTP Status 500 - Internal Server Error when i getting data from database
body: <p>HTTP Status 500 - Internal Server Error when i gatting data from the database. The query is working fine in the console but the restclient giving thw error. Here is my code.</p>
  
  <pre><code>@Entity
  @Table(name = "Patient")
  public class Patient {
  @Id @GeneratedValue(strategy=GenerationType.AUTO)
  private int patientId;
  private String firstName;
  private String lastName;
  private int age;
  private String cnic;
  private String contactNumber;
  private String homeNumber;
  private String country;
  private String city;
  private String town;
  private String streetNo;
  private String houseNo;
  private String email;
  private String username;
  private String password;
  
  @OneToMany(cascade=CascadeType.ALL, mappedBy="patient", fetch=FetchType.EAGER) 
  private Collection&lt;Vitals&gt; vitals = new ArrayList&lt;Vitals&gt;();
  
  
  
  
  public int getPatientId() {
      return patientId;
  }
  public void setPatientId(int patientId) {
      this.patientId = patientId;
  }
  public String getFirstName() {
      return firstName;
  }
  public void setFirstName(String firstName) {
      this.firstName = firstName;
  }
  public String getLastName() {
      return lastName;
  }
  public void setLastName(String lastName) {
      this.lastName = lastName;
  }
  public int getAge() {
      return age;
  }
  public void setAge(int age) {
      this.age = age;
  }
  public String getCnic() {
      return cnic;
  }
  public void setCnic(String cnic) {
      this.cnic = cnic;
  }
  public String getContactNumber() {
      return contactNumber;
  }
  public void setContactNumber(String contactNumber) {
      this.contactNumber = contactNumber;
  }
  public String getHomeNumber() {
      return homeNumber;
  }
  public void setHomeNumber(String homeNumber) {
      this.homeNumber = homeNumber;
  }
  public String getCountry() {
      return country;
  }
  public void setCountry(String country) {
      this.country = country;
  }
  public String getCity() {
      return city;
  }
  public void setCity(String city) {
      this.city = city;
  }
  public String getTown() {
      return town;
  }
  public void setTown(String town) {
      this.town = town;
  }
  public String getStreetNo() {
      return streetNo;
  }
  public void setStreetNo(String streetNo) {
      this.streetNo = streetNo;
  }
  public String getHouseNo() {
      return houseNo;
  }
  public void setHouseNo(String houseNo) {
      this.houseNo = houseNo;
  }
  public String getEmail() {
      return email;
  }
  public void setEmail(String email) {
      this.email = email;
  }
  public String getUsername() {
      return username;
  }
  public void setUsername(String username) {
      this.username = username;
  }
  public String getPassword() {
      return password;
  }
  public void setPassword(String password) {
      this.password = password;
  }
  public int getId(){
      return patientId;
  }
  
  public Patient getPatient(){
      return this;
  }
  public Collection&lt;Vitals&gt; getVitals() {
      return vitals;
  }
  public void setVitals(Collection&lt;Vitals&gt; vitals) {
      this.vitals = vitals;
  }
  }
  </code></pre>
  
  <p>Service Class Method getting data from database:</p>
  
  <pre><code>@SuppressWarnings("unchecked")
  public ArrayList&lt;Patient&gt; getAllPatients(){
      ArrayList&lt;Patient&gt; retPatient = new ArrayList&lt;Patient&gt;();
      try{
          sessionFactory = new Configuration().configure().buildSessionFactory();
          Session session = sessionFactory.openSession();
          retPatient = (ArrayList&lt;Patient&gt;) session.createCriteria(Patient.class).list();
          session.close();
      }catch(Exception ex){
          ex.printStackTrace();
      }
      return retPatient;
  }
  </code></pre>
  
  <p>Console Output:</p>
  
  <pre><code>Hibernate: select this_.patientId as patientId5_1_, this_.age as age5_1_, this_.city as city5_1_, this_.cnic as cnic5_1_, this_.contactNumber as contactN5_5_1_, this_.country as country5_1_, this_.email as email5_1_, this_.firstName as firstName5_1_, this_.homeNumber as homeNumber5_1_, this_.houseNo as houseNo5_1_, this_.lastName as lastName5_1_, this_.password as password5_1_, this_.streetNo as streetNo5_1_, this_.town as town5_1_, this_.username as username5_1_, vitals2_.patient_patientId as patient8_5_3_, vitals2_.vitalId as vitalId3_, vitals2_.vitalId as vitalId7_0_, vitals2_.bpHigh as bpHigh7_0_, vitals2_.bpLow as bpLow7_0_, vitals2_.heartBeat as heartBeat7_0_, vitals2_.patient_patientId as patient8_7_0_, vitals2_.respiratoryRate as respirat5_7_0_, vitals2_.suger as suger7_0_, vitals2_.temperature as temperat7_7_0_ from Patient this_ left outer join Vitals vitals2_ on this_.patientId=vitals2_.patient_patientId
  </code></pre>
  
  <p>Can anyone tell me that what i am doing wrong here. I shall be thankful :)</p>