subselect « Criteria « JPA Q&A





1. Controlling Hibernate's generated subselect    stackoverflow.com

Consider the following three Hibernate entities:

public class Car {

  @OneToMany(fetch = FetchType.LAZY)
  @Fetch(FetchMode.SUBSELECT)
  private List<Wheel> wheels;

}

public class Wheel {

  @OneToOne(fetch = FetchType.LAZY)
  private Hubcap hubcap;

}

public class ...

2. Criteria with subselect    stackoverflow.com

I need create a query in Java using Hibernate Criteria. I create a similar query in MySql, but I don't know how to do this in Hibernate. Follow below the sample:

select categoria_new, count(*) ...

3. Problems with subselect and DetachedCriteria    forum.hibernate.org

I sure am glad you made that post, you saved me some time =) I ran into the same NPE doing the same thing you were doing, and was just about ready to go to the code base myself. Adding a projection was just the ticket. It's been so long that I'm sure you've got a solution to your second problem ...

4. criteria with subselect    forum.hibernate.org

getting closer i think but: Criteria criteria = session.createCriteria(ClassName.class); DetachedCriteria dc = DetachedCriteria.forClass(ClassName.class) .add(Restrictions.gt("id", new Integer(id))) .setProjection(Projections.min("id")); criteria.add(Subqueries.eq("id",dc)); still not working. sql comes out to : select this_.TITLE_ID as TITLE1_0_0_, this_.TITLE as TITLE0_0_, this_.DATE_STRING as DATE3_0_0_ , this_.LIST_DATE as LIST4_0_0_ from top_ten_title this_ where ? = (select min(this0__.TITLE_ID) as y0_ from top_ten_title this0__ where this0__.TITLE_ID>?) i'm curious about the line with ...

5. Criteria, subselect    forum.hibernate.org

Hello. I really hope, that you can help me. I have entity class, called property and it has OneToMany relation with Image: Code: private Set images; @OneToMany(fetch = FetchType.EAGER) @Where(clause="source_type = 1") @JoinColumn(name="source_id", nullable = true) public Set getImages() { ...