title: Expected positional parameter count: 2, actual parameters:
body: <p>Hello everyone I have an exception when I try to execute my code:
  Also please tell my how to pass to parameters to query or maybe use </p>
  
  <p>My DAO:</p>
  
  <pre><code>@Override
      public Institution findWIthTwoParam(String name, Date mydate) {         
        return (Institution)sessionFactory.getCurrentSession().createQuery(
           "select i from Institution i where i.nameOfInstitution =? and i.creationDate=?")
           .setString(0, name)
           .setParameter(1, mydate).uniqueResult();
  
      }
  </code></pre>
  
  <p>My stack of exception:</p>
  
  <pre><code>Exception in thread "main" org.hibernate.QueryException: Expected positional parameter count: 2, actual parameters: [MyIstitution, Tue Apr 27 00:00:00 EST 17] [select i from Institution i where i.nameOfInstitution =? and i.creationDate=?]
      at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:366)
      at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:322)
      at org.hibernate.impl.QueryImpl.list(QueryImpl.java:98)
      at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:890)
      at edu.demidov.dao.InsertDataService.findWIthTwoParam(InsertDataService.java:106)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
      at $Proxy25.findWIthTwoParam(Unknown Source)
      at edu.demidov.dao.AppTEst.main(AppTEst.java:76)
  </code></pre>
  
  <p>My entity:</p>
  
  <pre><code>@Entity
  @Table(name="INSTITUTION")
  public class Institution implements Serializable{
  
  
      private static final long serialVersionUID = -7636394097858726922L;
  
              @Id
          @GeneratedValue(strategy=GenerationType.IDENTITY)
          @Column(name="INSTITUTION_ID")
      private int institutionId;
  
  
          @Version
          @Column(name="VERSION")
      private int version;
  
  
              @Column(name="NAME_INSTITUTION")
      private String nameOfInstitution;
  
  
                   @Column(name="TYPE_NAME")
      private String typeName;
  
  
          @ManyToMany(mappedBy="institution", fetch = FetchType.LAZY)
          @Cascade(org.hibernate.annotations.CascadeType.ALL)
      private Set&lt;CreationDate&gt; creationDate = new HashSet&lt;CreationDate&gt;();
  
          //getter and setter methods ommited
  
          public String toString() {
              return institutionId + " , " + nameOfInstitution + " , " + typeName 
          }       
  }
  </code></pre>
  
  <p>My entity two:</p>
  
  <pre><code>@Entity
  @Table(name="CREATION_DATE")
  public class CreationDate implements Serializable {
  
  
      private static final long serialVersionUID = 1648102358397071136L;
  
                   @Id
          @GeneratedValue(strategy=IDENTITY)
          @Column(name="DATE_ID")
      private int dateId;
  
  
          @Column(name="PARTICULAR_DATE")
      private Date particularDate;
  
  
              @Version
          @Column(name="VERSION")
      private int version;
  
  
          @Temporal(TemporalType.DATE)
          @Column(name="CHILD_GO_SCHOOL_DATE")
      private Date childGoSchoolDate;
  
  
          @Temporal(TemporalType.DATE)
          @Column(name="CHILD_ADMISSION_DATE")
      private Date childAdmissionDate;
  
  
          @ManyToMany(fetch = FetchType.LAZY)
          @Cascade(org.hibernate.annotations.CascadeType.ALL)
          @JoinTable(name="CREATIONDATE_INSTITUTION", 
                                      joinColumns=@JoinColumn(name="DATE_ID"), 
                                      inverseJoinColumns=@JoinColumn(name="INSTITUTION_ID"))
      private Set&lt;Institution&gt; institution = new HashSet&lt;Institution&gt;();
  
  
                        @OneToMany(fetch=FetchType.EAGER, orphanRemoval=true)
          @Cascade(org.hibernate.annotations.CascadeType.ALL)
          @JoinTable(name="SRC_DATE", joinColumns=@JoinColumn(name="DATE_ID"),
                      inverseJoinColumns=@JoinColumn(name="SRC_ID"))
      private List&lt;ScheduleRotationChild&gt; scheduleRotationChild = new ArrayList&lt;ScheduleRotationChild&gt;();
  
  
          //getter and setter methods ommited
  
  
          public String toString() {
  
              return  dateId + " , " 
              + particularDate + " , " 
              + childGoSchoolDate + " , " 
              + childAdmissionDate + "  " + scheduleRotationChild ;
  
          }
  
  }
  </code></pre>
  
  <p>Please help me to solve it. </p>