I have an entity witch map with PERSON table
@Entity
@Table(name = "PERSON")
public class PersonEntity implements Serializable {
protected static final long serialVersionUID = 1L;
protected int numPerson;
protected String sex;
...
protected Collection childs;
@Id( generate = GeneratorType.AUTO)
@Column (name = "NUM_PERSON")
public int getNumPerson() {
return numPerson;
}
public void setNumPerson(int numPerson) {
this.numPerson = numPerson;
}
@Column (name = "SEX")
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
..
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY,
mappedBy="father")
@JoinColumn(name="FK_PERSON_FATHER") // Foreign key in PERSON
public Collection getChilds() {
return childs;
}
public void setChilds(Collection childs) {
this.childs = childs;
}
}
My problem is:
I need to load "childs" collection by joint on FK_PERSON_FATHER column if
SEX='M' or by joint on FK_PERSON_MOTHER column if SEX='W'.
(In the exemple above the joint is done on FK_PERSON_FATHER)
Is it possible to do that ?
here is the DDL of "PERSON" table
CREATE TABLE PERSON (
NUM_PERSON INTEGER AUTO_INCREMENT NOT NULL
,SEX VARCHAR(1) NOT NULL
,FK_PERSON_FATHER INTEGER
,FK_PERSON_MOTHER INTEGER
,PRIMARY KEY (NUM_PERSON)
);
INSERT INTOPERSON (NUM_PERSON,SEX) VALUES
(1,'racin','racin','racin','racin','M');
ALTER TABLE PERSON ADD (
FOREIGN KEY (FK_PERSON_FATHER) REFERENCES PERSON(NUM_PERSON)
,FOREIGN KEY (FK_PERSON_MOTHER) REFERENCES PERSON(NUM_PERSON)
);
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3925348#3925348
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3925348
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user