Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to JOIN three tables using criteria api and metamodel

 
Brian Storenson
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have three tables Lesson, Course, Program. Lesson has an attribute for Course's uuid, Course has an attribute for Program's uuid. How can I translate this to a Criteria API expression? Right now my statement returns a Path, and it's not returning any tuples.

I wrote out some sql to help me figure out what I needed to do. I think it should look something like this:

SELECT *
FROM Lesson AS l
INNER JOIN Course AS c
ON l.Course=c.uuid
INNER JOIN Program AS p
ON c.program=p.uuid
WHERE p.uuid = 'LessonSearchCriteria.PROGRAM_ID'


I am creating a dynamic query method that can search by Program_ID and by other characteristics if needed. My code looks like this as of right now:



I have also tried using the String versions of the join and get methods. Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic