Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Criteria query select specific columns from several entities  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an entity A, which has entity B and B has entity C : A -> B -> (collection of C)
I want to form a criteria query and select all columns from A, all columns from B and specific columns from C.
I wrote a query using Criteria and Projections, but its querying only the specified columns of entity C and none from A or B.

Here is my query :
Criteria crit = s.createCriteria(A.class, "tableA")
.add(Restrictions.eq("Id", 100))
.createAlias("b", "tableB")
.createAlias("tableB.c", "tableC");

ProjectionList proList = Projections.projectionList();

Can somebody tell me how can I tune this query ?
Thanks much in advance.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!