title: Retrieve primary key from table with HQL
body: <p>I have a table that is | <strong>CustomerId</strong> | CustomerName | CustomerCountry |. </p>
  
  <p>How can I write an HQL query to retrieve the CustomerId that corresponds with the combination of a CustomerName and a CustomerCountry?</p>
  
  <p>here is my CustomerDaoImpl: </p>
  
  <pre><code>@Repository
  public class CustomerDaoImpl implements CustomerDao {
  
  @Autowired(required=true)
  private SessionFactory sessionFactory;
  
  public Customer getCTID(String customerName, String customerCountry) {
      return (Customer) 
  this.sessionFactory.getCurrentSession().createQuery(/* Some query that gets CTID corresponding to customerName and customerCountry*/);
  
  }
  }
  </code></pre>
  
  <p>I want to use this CustomerId and insert it into my DeliveryTable for a new delivery. I am using a DTO for the form where the delivery information is entered and I will be using a DeliveryService for creating the new delivery that uses a CustomerService to retrieve the CustomerId with a CusomerDAO.</p>
  
  <p>Thank you for your help,
  D</p>