My Tables:
Product: id, name
Offer: id, value, product_id
Entities:
@Entity
@Table(name="product")
public class Product implements Serializable {
@OneToMany(mappedBy="product")
private Set<Offer> offers;
...
}
@Entity
@Table(name="offer")
public class Offer implements Serializable {
@ManyToOne
@JoinColumn(name="PRODUCT_ID")
private Product product;
...
}
When I try to get some data from table Product
, I get a java.lang.NullPointerException
, and this code: product.getOffers()
returns:
{IndirectSet: not instantiated}
How to fix this?