hibernate - Join an association multiple times with different aliases -


i think, problem have bug in hibernate (already tracked - https://hibernate.onjira.com/browse/hhh-879 ).

my question - there workaround join table multiple times grails criteria query?

the sql straight forward:

select s store s        inner join s.products prod1       inner join s.products prod2        prod1.type = 'shoes'    ,      prod2.type = 'shirts'  

when use "createalias" in grails criteria query (one prod1 , 1 prod2) i´am getting following error:

org.hibernate.queryexception: duplicate association path: studytags ...

one possibilty might by, query or (one single join , prod.type = 'shoes' or 'shirts') , filter result set. problem solution is, if specify limit criteria query (max results), real result (after filtering) might have less entries specified.

any appreciated.

thanks.

ps: real code, experienced issue pretty complex. break problem down used example store , product... think query like

store.withcriteria{     createalias('products', 'prod1')     createalias('products', 'prod2')      and{         eq('prod1.type', 'shoes')         eq('prod2.type', 'shirts')     } } 

although old question came acroos when searching solution. figured out there bug in hibernate make duplikacte aliases impossible. work around used using pure sql finding limited "id's" list , there check if other query requrements matched list. in example be"

select x.id xtable x join products prod1 on... join products prod1 on... prod1.type= 'shoes' , prod.type = 'shirts'; 

and check

select x.id xtable x x.id in ("result of query") 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -