I have three classes, Site, GoupIP and IP
A Site has one or many GrouIPs.
A GroupIP has one or many IPs.
Here is the code:
Site Code:
@Entity
@Table(name = "site")
public class Site implements Serializable {
private Set<GroupIp> groups;
@OneToMany(mappedBy = "site", fetch = FetchType.EAGER, cascade =CascadeType.ALL)
public Set<GroupIp> getGroups() {
return groups;
}
public void setGroups(Set<GroupIp> groups) {
this.groups = groups;
}
}
GroupIP Code:
@Entity
@Table(name = "groupip")
public class GroupIp implements Serializable {
private Set<Ip> ips;
private Site site;
@ManyToOne(cascade = CascadeType.MERGE)
@JoinColumn(name = "site_id")
public Site getSite() {
return site;
}
@OneToMany(mappedBy = "groupip", fetch = FetchType.EAGER, cascade =CascadeType.ALL)
public Set<Ip> getIps() {
return ips;
}
public void setIps(Set<Ip> ips) {
this.ips= ips;
}
}
IP Code:
@Entity
@Table(name = "ip")
public class Ip implements Serializable {
private GroupIp groupIp;
@ManyToOne(targetEntity = GroupIp.class,cascade = CascadeType.MERGE)
@JoinColumn(name = "groupip_id", nullable=false)
public GroupIp getGroupIp() {
return groupIp;
}
public void setGroupIp(GroupIp groupIp) {
this.groupIp = groupIp;
}
}
On GroupIp class, I m getting:
*In attribute 'ips', the "mapped by" value 'groupip' cannot be resolved to an attribute on the target entity.*
Whats wrong on my code ??