0 Replies Latest reply: Nov 21, 2007 3:34 AM by Frank Heldt RSS

    question about @ManyToOne and @Where

    Frank Heldt Newbie

      I've got a nasty problem and no idea how to solve this.

      First: This is a legacy database, which i cannot change :-(

      I have 2 entities Drvor and Vdrau both with the same compound key. Vdrau contains additional information, but only if the column DVABNR is >1500

      With this solution it works (i had to add the @NotFound annotation, see below), but not optimal. It generates a seperate sql call for every row that has no data in Vdrau.

      I looked at the @WhereJoinTable annotation, but it doesn't work with @MayToOne :-(

      @Entity
      public class Drvor implements Serializable {
       @EmbeddedId
       private DrvorPK pk = new DrvorPK();
      
       @ManyToOne(fetch = FetchType.LAZY)
       @Fetch(FetchMode.JOIN)
       @JoinColumns({
       @JoinColumn(name="DVAUN1", insertable=false, updatable=false),
       @JoinColumn(name="DVAUN2", insertable=false, updatable=false),
       @JoinColumn(name="DVAUJJ", insertable=false, updatable=false),
       @JoinColumn(name="DVABNR", insertable=false, updatable=false)
       })
       @NotFound(action=NotFoundAction.IGNORE)
       public Vdrau vdrau;
       ...
      }