title: The multi part identifier "subscript0_1_.partenaire_id" can not be bound after upgrading hibernate from 3 to 4
body: <p>So i'm building a project with hibernat 4.0.1.FINAL and SPring 3.2.3.RELEASE And i'm trying to execute this query</p>
  
  <pre><code>StringBuffer requete = new StringBuffer("select distinct new ma.mamda.per.model.Souscription(souscription.id, ")
          .append("souscription.numeroPolice, souscription.dateEffet, souscription.cotisationPeriodique.epargne.montant,souscription.produit.familleproduit.code, ")
          .append("souscription.garntieOptionnelle, souscription.dureeContrat, souscription.etat, ")
          .append(" souscription.souscripteur.nom, souscription.souscripteur.prenom,souscription.partenaire.libelle,souscription.partenaire.id,souscription.produit.libelle,assure.numeroCompte, assure.nom, assure.prenom)")
  .append(" from  ma.mamda.per.model.Souscription as  souscription left outer join  souscription.souscripteur as souscripteur")
  .append(" left outer join  souscription.cotisationPeriodique as cotisationPeriodique")
  .append(" left outer join  souscription.cotisationPeriodique.epargne as epargne ")
  .append(" left outer join  souscription.partenaire as partenaire ")
  .append(" left outer join  souscription.produit as produit")
  .append(" left outer join  souscription.produit.familleproduit as familleproduit ");
  if(notEmpty(rechercheContratBean.getNumCompteBancaire())){
      requete.append(" left outer join  souscription.compte as compte ");
  }
      requete.append(" left outer join  souscription.assure as assure ");
  if(notEmpty(rechercheContratBean.getIdTypeAvenant())){
      requete.append(" left outer join  souscription.historiques as historiques ");
  }
  if(notEmpty(rechercheContratBean.getNumSinistre())){
      requete.append(" left outer join  souscription.rachatTotal as rachatTotal ")
      .append(" left outer join  souscription.rachatsPartiel as rachatsPartiel ");
  }
  requete.append(" where  souscription.etat != ").append(rechercheContratBean.ACTION_EN_ATTENTE_VALIDATION);
  requete.append(" and  souscription.etat != ").append(rechercheContratBean.ACTION_INVALIDE);
  if(notEmpty(rechercheContratBean.getStatut())){
      requete.append(" and souscription.etat = ").append(rechercheContratBean.getStatut());
  }
  if(notEmpty(rechercheContratBean.getNumPolice())){
      requete.append(" and numeroPolice like '%").append(rechercheContratBean.getNumPolice().trim()).append("%'");
  }
  if(notEmpty(rechercheContratBean.getNumCompteBancaire())){
      requete.append(" and compte.numCompteBancaire like '%").append(rechercheContratBean.getNumCompteBancaire().trim()).append("%'");
  }
  if(notEmpty(rechercheContratBean.getNomAssure())){
      requete.append(" and assure.nom like '%").append(rechercheContratBean.getNomAssure().trim()).append("%'");
  }
  if(notEmpty(rechercheContratBean.getNomSouscripteur())){
      requete.append(" and souscripteur.nom like '%").append(rechercheContratBean.getNomSouscripteur().trim()).append("%'");
  }
  if(notEmpty(rechercheContratBean.getIdTypeAvenant())){
      requete.append(" and historiques.typeAvenant.id = ").append(rechercheContratBean.getIdTypeAvenant());
  }   
  if(notEmpty(rechercheContratBean.getNumSinistre())){
      requete.append(" and (rachatTotal.numeroSinistre = ").append(rechercheContratBean.getNumSinistre())
      .append(" or rachatsPartiel.numeroSinistre = ").append(rechercheContratBean.getNumSinistre()).append(" )");
  }   
  if(notEmpty(rechercheContratBean.getIdProduit())){
      requete.append(" and produit.id = ").append(rechercheContratBean.getIdProduit());
  }
  if(notEmpty(rechercheContratBean.getIdPartenaire())){
      requete.append(" and partenaire.id = ").append(rechercheContratBean.getIdPartenaire());
  }   
  Query q = genericDAO.createQuery(requete.toString());
  </code></pre>
  
  <p>And I'm trying to execute the following code:</p>
  
  <pre><code>Query q = getCurrentSession.createQuery(requete.toString());
  try {
      SscrollableResults scrollableResults = query.scroll(ScrollMode.FORWARD_ONLY);
      int totalElements = scalculateTotalElementsByList(query);
  } catch (HibernateException e) {
      if (log.isErrorEnabled())
          log.error("Failed to create ScrollPage by getScrollPageInstanceWithTotalByQuery: " + e.getMessage());
      throw e;
  }
  </code></pre>
  
  <p>The code fails in scrollableResults = query.scroll(ScrollMode.FORWARD_ONLY); and throws the following exception:</p>
  
  <pre><code>org.hibernate.exception.SQLGrammarException: Failed to create ScrollPage by getScrollPageInstanceWithTotalByQuery: The multi part identifier "subscript0_1_.partenaire_id" can not be bound
  Root Cause : com.microsoft.sqlserver.jdbc.SQLServerException: The multi part identifier "subscript0_1_.partenaire_id" can not be bound
  </code></pre>
  
  <p>Here is my <code>Partenaire</code> class</p>
  
  <pre><code>@Entity
  @Inheritance
  @DiscriminatorColumn(name="type_partenaire")
  @Cache(usage =CacheConcurrencyStrategy.READ_WRITE)
  @BatchSize(size=1000)
  public  class Partenaire implements java.io.Serializable {
  
      private static final long serialVersionUID = -7532086016661782539L;
  
  
      private Integer id;
      private String  libelle;
      private String  code;
      private String numeroCompte;
      private String  raisonSocial;
      private String  inbox;
      private String  outbox;
      private Set&lt;Intermediaire&gt; intermediaires= new HashSet&lt;Intermediaire&gt;();
      private Set&lt;Produit&gt; produits = new HashSet&lt;Produit&gt;();
  
  
      public Partenaire() {
      }
      public Partenaire(Integer id) {
          this.id = id;
      }
      public Partenaire(String numeroCompte) {
          this.numeroCompte = numeroCompte;
      }
  
  
      public Partenaire(Integer idPartenaire, String libellePartenaire) {
          this.id= idPartenaire;
          this.libelle = libellePartenaire;
      }
  
      /**
       * @return the idPartenaire
       */
      @Id  @GeneratedValue @Column(name="id")
      public Integer getId() {
          return id;
      }
  
      public void setId(Integer id) {
          this.id = id;
      }
  
      public String getLibelle() {
          return libelle;
      }
  
      public void setLibelle(String libelle) {
          this.libelle = libelle;
      }
  
  
      public String getCode() {
          return code;
      }
  
      public void setCode(String code) {
          this.code = code;
      }
  
      public String getRaisonSocial() {
          return raisonSocial;
      }
  
      public void setRaisonSocial(String raisonSocial) {
          this.raisonSocial = raisonSocial;
      }
  
  
  
      @OneToMany(mappedBy="partenaire")
      //@JoinColumn(name="partenaire_id")
      public Set&lt;Produit&gt; getProduits() {
          return produits;
      }
  
      public void setProduits(Set&lt;Produit&gt; produits) {
          this.produits = produits;
      }
  
      public String getInbox() {
          return inbox;
      }
  
      public String getOutbox() {
          return outbox;
      }
  
      public void setInbox(String inbox) {
          this.inbox = inbox;
      }
  
      public void setOutbox(String outbox) {
          this.outbox = outbox;
      }
  
      @OneToMany(mappedBy="partenaire")
      //@JoinColumn(name="partenaire_id")
      public Set&lt;Intermediaire&gt; getIntermediaires() {
          return intermediaires;
      }
  
      public void setIntermediaires(Set&lt;Intermediaire&gt; intermediaires) {
          this.intermediaires = intermediaires;
      }
  
      public String getNumeroCompte() {
          return numeroCompte;
      }
  
      public void setNumeroCompte(String numeroCompte) {
          this.numeroCompte = numeroCompte;
      }
  
  }
  </code></pre>
  
  <p>The query used to work just fine in hibernate 3 but after the migration to hibernate 4 it throw the previous exception.
  Am i missing something ?</p>