3 Replies Latest reply on May 1, 2005 5:59 PM by epbernard

    "findBy" in reference after entity detached?

    neoalec

      I have the following type of situation: a @OneToMany relationship, EAGER fetch, the object on the "One" side is detached. Now I have access to the "Many" objects and can iterate over them, but instead, I would like to quickly access one using one of the properties, e.g.

      department.getUser("Bob')

      instead of having to iterate over department.getUsers() and check each name to match bob.

      Is there anything (automatic?) in place to make this simple? Or do I have to resort to making another function (e.g. getUserByName) to hide the iteration, or map users to a Hashtable when they first come in?

        • 1. Re:
          kabirkhan

          Your best be is probably to create a direct ejbql (entitymanager.createQuery()) query to load up what you want

          • 2. Re:
            neoalec

            The thing is the entities are detached and not yet persisted.. and I want access to the (possibly new) values.

            • 3. Re:
              epbernard

              merge before doing your ejbql query