0

How is it to use an alias in hibernate in a sqlRestriction .. Here is my code but it does not work, it does not recognize "emet" and "dest" as aliases

criteria.createAlias("personne", "emet", JoinFragment.INNER_JOIN);
criteria.createAlias("destinataire", "dest", JoinFragment.INNER_JOIN)
        .createCriteria("fichier")
        .add(Restrictions.sqlRestriction("({alias}.codic SIMILAR TO 'U[AB0-9]{4}' and emet.cod = 'ERF') OR (emet.codic SIMILAR TO '[^U]%' and dest.codic like 'AA%') OR (emet.codic SIMILAR TO 'U[AB0-9]{4}' and {dest}.codic SIMILAR TO '[^U]%')"));           
Alex Salauyou
  • 14,185
  • 5
  • 45
  • 67
  • can you please add more code snippet for better understating of what are you doing!!!! – Dev May 06 '15 at 12:25
  • Ok . I want use the alias "emet" and "dest" in my Restrictions.sqlRestriction but I don't khow how to do it – madisone May 06 '15 at 12:29
  • So I want translate this sql in hibernate `select * from pfr.message m inner join pfr.partenaire emet on m.idEmet=emet.idPart inner join pfr.partenaire dest2_ on m.idDest=dest.idPart where emet.codic SIMILAR TO 'U[AB0-9]{4}' and dest2_.codic = 'U0000'` – madisone May 06 '15 at 12:42
  • please refer http://stackoverflow.com/questions/2347359/hibernate-createcriteria-or-createalias – Dev May 06 '15 at 13:19

0 Answers0