title: How to fetch particular column stored procedure from hibernate
body: <p>I am trying to fetch user details from MYSQL database through the stored procedure using hibernate am getting:</p>
  
  <blockquote>
    <p>org.hibernate.exception.SQLGrammarException: could not execute query
    Caused by: java.sql.SQLException: Column 'create_time' not found.</p>
  </blockquote>
  
  <p>in MYSQL db I have taken timestamp data type for create_time<br>
  why?</p>
  
  <p><strong>My stored procedure</strong> </p>
  
  <pre><code>DELIMITER $$;
  
  DROP PROCEDURE IF EXISTS `BIM`.`getUserDetailsSP`$$
  
  CREATE DEFINER=`mariadb`@`%` PROCEDURE `getUserDetailsSP`(IN in_email VARCHAR(255))
  BEGIN
      SELECT UserID, a.UserTypeID, b.UserTypeName,firstname,lastname,phone
      FROM BIM.UserDetailsV a 
      JOIN BIM.UserTypeDetailsV b ON a.UserTypeID = b.UserTypeID 
      WHERE a.email = in_email;
  END$$
  
  DELIMITER ;$$
  </code></pre>
  
  <p><strong>Hibernate</strong></p>
  
  <pre><code>try{
      Session session = sessionFactory.openSession();
      Query query = session.createSQLQuery(
              "CALL getUserDetailsSP(:email)")
              .addEntity(UserDTO.class)
              .setParameter("email", "bob@gmail.com");
  
          List result = query.list();
          for(int i=0; i&lt;result.size(); i++){
              UserDTO stock = (UserDTO)result.get(i);
              System.out.println(stock.getFirstName());
          }
      }catch (HibernateException e) {
          e.printStackTrace();
  
      } 
  </code></pre>
  
  <p><strong>UserDTO</strong></p>
  
  <pre><code>public class UserDTO implements Serializable{
      @Id
      @GenericGenerator(name = "j", strategy = "increment")
      @GeneratedValue(generator = "j")
      @Column(name = "UserID")
      private long userID;
  
      @Column(name = "UserTypeID")
      private long userTypeID;
  
      @Column(name = "firstname")
      private String firstName;
  
      @Column(name = "lastname")
      private String lastName;
  
      @Column(name = "email")
      private String email;
  
      @Column(name = "phone")
      private String phone;
  
      @Column(name = "password")
      private String password;
  
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name = "create_time")
      private Date create_time;
  
      @Column(name = "update_time")
      private Date update_time;
  // getters and setters
  }
  </code></pre>