Thanks Guy,
But i didn't solved my problem! i'm posting all my code :
CUSTOMER ENTITY (table with 2 colums named (id, message))
____________________________________________________
@Entity
@Table(name = "customer")
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "id", nullable = false)
private Integer id;
@Column(name = "message")
private String message;
@OneToMany(mappedBy = "idcustomer")
private Collection<Card> cardCollection;
public Serializable getMessage() {
return message;
}
public void setMessaggio(String _message) {
this.message = _message;
}
public Collection<Card> getCardCollection() {
return cardCollection;
}
public void setCardCollection(Collection<Card> _cardCollection) {
this.cardCollection = _cardCollection;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Customer)) {
return false;
}
Customer other = (Customer) object;
if ((
this.id == null &&
other.id != null) || (
this.id != null && !this.id.equals(
other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "newpackage.Customer[id=" + id + "]";
}
}
CARD ENTITY (table with 3 colums named (id, biometricpwd, idcustomer))
_____________________________________________________________
@Entity
@Table(name = "card")
public class Card implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "id", nullable = false)
private Integer id;
@Column(name = "biometricpwd")
private Boolean biometricpwd;
@JoinColumn(name = "idcustomer", referencedColumnName = "id")
@ManyToOne
private Customer idcustomer;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Boolean getBiometricpwd() {
return biometricpwd;
}
public void setBiometricpwd(Boolean biometricpwd) {
this.biometricpwd = biometricpwd;
}
public Customer getIdcustomer() {
return idcustomer;
}
public void setIdcustomer(Customer _idcustomer) {
this.idcustomer = _idcustomer;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Card)) {
return false;
}
Card other = (Card) object;
if ((
this.id == null &&
other.id != null) || (
this.id != null && !this.id.equals(
other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "newpackage.Card[id=" + id + "]";
}
}
Idcustomer is an imported key from table customer.
How can i obtain all cards finding a customer??
Thanks in advance.
2008/9/11 Guy Pelletier
<guy.pelletier@xxxxxxxxxx>
Hi,
Your mapped by is incorrect and should be specified as follows: mappedBy="relateda"
And your JoinColumn is inversed. It should be
@JoinColumn(name="Akeyname", referencedColumnName="Bkeyname")
Cheers,
Guy
----- Original Message ----- From: "SerFingolfin" <paolo.trisio@xxxxxxxxx>
To: <eclipselink-users@xxxxxxxxxxx>
Sent: Thursday, September 11, 2008 6:26 AM
Subject: [eclipselink-users] Newbie mapping question