I´ve got this Model on my Play application.
@Entity
@Table(name="SHOPPER")
public class User extends GenericModel {
...
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "SASHNBR", insertable = true, updatable = true)
public List<Direction> directions;
}
The Direction Model looks like this
@Entity
@Table(name="SHADDR")
public class Direccion extends GenericModel {
...
@Column(name="SASHNBR")
@Required
public Long idUser;
}
This way I´ve got an error because Direction doens’t have the idUser generated when saving.
I´ve tried this way too.
@Entity
@Table(name="SHOPPER")
public class User extends GenericModel {
...
@OneToMany(cascade = CascadeType.ALL, mappedBy="user")
public List<Direction> directions;
}
The Direction Model looks like this
@Entity
@Table(name="SHADDR")
public class Direccion extends GenericModel {
...
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name = "SASHNBR", insertable = true, updatable = true)
User user;
}
But it didn’t work either.
Can someone help me with this?
Thanks! 🙂
You will need to save the children your self. You can look at the tutorial for an example.