Hi
Hope someone can helpe me. I'm stuck here.Having two objects:
@XmlRootElement
@Entity
public class Produkt implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"Produkt_id_seq")
private Integer id;
...
@XmlElement(name = "varelagers")
@OneToMany(cascade = CascadeType.ALL, mappedBy = "produkt", fetch =
FetchType.EAGER)
private List<Varelager> varelagers;
public List<Varelager> getVarelager() {
return this.varelagers;
}
..
}
and
@Entity
public class Varelager implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"Varelager_id_seq")
private Integer id;
......
@ManyToOne
@JoinColumn(name = "produkt_id")
private Produkt produkt;
@ManyToOne
@JoinColumn(name = "storelse_id")
private Storelse storelse;
public Produkt getProdukt() {
return produkt;
}
public void setProdukt(Produkt produkt) {
this.produkt = produkt;
}
}
I've created an webservice that exposes both produkt and varelager.
And I'm trying to add a "varelager" to "produkt", using the webservice.
But here my objects does not have all the same methods.
I'm missing Varelager.getProdukt(), and Varelager.setProdukt(Produkt
produkt).
Anyone who can tell me why??
I've allso tried this as a workarround
Produkt p = webservice.getproddukt(new Integer(1));
Varelager vl = new Varelager();
vl = webservice.createVarelager(vl);
p.getVarelagers().add(vl);
webservice.editProdukt(p);
This creates the varelager object, but does not set any Produkt.
Any other way?
--
View this message in context: http://www.nabble.com/%40OneToMany---%40ManyToOne-WebService-and-%40XmlRootElement-tf4405404.html#a12568202
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.