2 Replies Latest reply on Apr 26, 2006 11:50 AM by villi

    Filling nested collections with specific values

      Hi,

      i have a problem with an EJB-QL Query.
      I have following entities, which are nested in collections
      Project(1)->(N)Task(1)->(N)SubTask

      @Entity
      public class Project{
       @OneToMany
       List<Task> tasks;
      }


      @Entity
      public class Task {
       @ManyToOne
       Project project;
      
       @OneToMany
       List<SubTask> subTasks;
      }


      @Entity
      public class SubTask {
       @ManyToOne
       Task task;
      
       User user;
      }


      @Entity
      public class User {
       String login;
      }


      I want to retrieve all Projects in which a user is involved.
      Additional the Collections should only include the Tasks which includes the SubTasks assigned to this user.

      I have tried the following Query but the Project which was found includes all Tasks in the List.

      select p from Project as p
      inner join p.tasks as t
      inner join t.subTasks as s
      inner join s.user as u
      where u.login = :username


      Any ideas?

      Thanks,

      klaro78