J'ai deux tables en relation 1-n
T_User & T_Service
Càd un id de T_Service peut se retrouver plusieurs fois dans T_User
T_Service <1 -- n> T_User
Voici mes classes mapper par Toplink :
import java.util.ArrayList;
import java.util.List;
import oracle.toplink.indirection.ValueHolder;
import oracle.toplink.indirection.ValueHolderInterface;
public class TUser {
/**Map tService <-> ......bo.TService
* @associates <{......bo.TService}>
*/
private ValueHolderInterface tService;
private Double id;
private String firstname;
private String lastname;
public TUser() {
super();
this.tService = new ValueHolder();
}
public String getFirstname() {
return this.firstname;
}
public Double getId() {
return this.id;
}
public String getLastname() {
return this.lastname;
}
public TService getTService() {
return (TService)this.tService.getValue();
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public void setId(Double id) {
this.id = id;
}
public void setTService(TService tService) {
this.tService.setValue(tService);
}
}
package .........bo;
import java.util.ArrayList;
import java.util.List;
public class TService {
/**Map tUserCollection <-> .........bo.TUser
* @associates <{.........bo.TUser}>
*/
private List tUserCollection;
private Double id;
private String name;
private String code;
public TService() {
super();
this.tUserCollection = new ArrayList();
}
public void addTUser(int index, TUser aTUser) {
this.tUserCollection.add(index, aTUser);
aTUser.setTService(this);
}
public void addTUser(TUser aTUser) {
this.tUserCollection.add(aTUser);
aTUser.setTService(this);
}
public String getCode() {
return this.code;
}
public Double getId() {
return this.id;
}
public String getName() {
return this.name;
}
public List getTUserCollection() {
return this.tUserCollection;
}
public void removeTUser(TUser aTUser) {
this.tUserCollection.remove(aTUser);
aTUser.setTService(null);
}
public void setCode(String code) {
this.code = code;
}
public void setId(Double id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setTUserCollection(List tUserCollection) {
this.tUserCollection = tUserCollection;
}
}
Je n'arrive pas à attribuer un id du Service à un User ....
Partager