-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Optionale @ManyToOne Verknüpfung
PostPosted: Wed Feb 17, 2010 10:43 am 
Newbie

Joined: Wed Jul 19, 2006 4:13 am
Posts: 6
Hallo,

ich habe zwei Entities, die beide über die gleiche Id verknüpft sind.

Code:
@Entity
public class A {
    @Id
    private int id;
 
    @ManyToOne(optional=true)
    @JoinColumns(name="id", referencedColumnName="id", insertable=false, updateable=false)
    private B b;
   
}

@Entity
public class B {
    @Id
    private int id;
}



Es gibt jedoch nicht für jedes A auch ein B.

Daher erhalte ich von Hibernate die Fehlermeldung

Code:
javax.persistence.EntityNotFoundException: Unable to find B with id {6C5FCDFE-1A7B-426E-8E70-F38AD2EBA0F4}


Gibt es eine Möglichkeit daraus quasi einen left join zu machen? Das heißt er soll halt A.b auf null setzen wenn er B nicht findet.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.