[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - question about @ManyToOne and @Where

fheldt do-not-reply at jboss.com
Wed Nov 21 03:34:30 EST 2007


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;
  |   ...
  | }
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4106639#4106639

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4106639



More information about the jboss-user mailing list