0 Replies Latest reply on Mar 11, 2008 10:54 AM by nes

    Using the persistence manager in an entity bean

    nes

      Greetings!

      I have an entity bean called person which has a 1:n relationship to another entity bean called job, which contains all jobs that this person has ever had.

      now, i'd like to have a function in person, which gives me only one of these jobs, namely the one he's currently working for.

      i did it already, and it nearly works, it looks like this:

      Job s;
      @Transient
      public Stelle getCurrentJob() {
      if(s==null){
      EntityManager em = (EntityManager) Component.getInstance("entityManager");
      Long sid = (Long) em.createQuery("fanceql").setParameter("id", this.id).getSingleResult();
      s = em.find(Job.class,sid);
      }
      return s;
      }

      The problem is, that changes to Job are not saved to the database. why aren't they?

      is this bad design? how would you do it?

      niko