hibernate - Criteria with collections -


i having rough time dealing hibernate criteria , collections.

i have following relations:

  • a has many elements of b
  • a has 1 element of c
  • c has many elements of d
  • d has 1 element of e

so basically

e<----1----d<--------c<----1----a--------->b

i trying fetch elements of c elements verify conditions on c's attributes, plus have @ least 1 element d related specific e.

so criteria far:

session.createcriteria(a.class)                 .createcriteria("cs")                 .add(restrictions.or(restrictions.eq("attributea", 1), restrictions.eq("attributeb", 2)))                 .createcriteria("ds")                 .createcriteria("e")                 .add(restrictions.eq("id", 123); 

this works okay, sql getting hibernate result select attributes of c, d , e, don't need (only need filter them). how can restrict these , use relations filtering?

also, want elements b fetched, otherwise getting collection have initialize individually, results in lot more queries. how can build criteria includes those?


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -