I'm having the same problem.
As an example:
@Entity
public class User extends Model {
private String name;
@OneToMany(cascade = CascadeType.PERSIST)
private List<Role> roles;
// ...
}
@Entity
public class Role extends Model {
private String name;
// ...
}
Now if I just want to create a new role like this:
new Role("admin").save()
I get the following (same) error:
Error inserting bean [class
models.Role] with unidirectional relationship. For inserts you must
use
cascade save on the master bean [class models.User].
I mean it even says the the relation is unidirectional.
So why shouldn't I be able to insert Roles indepdently?
~ Markus
On May 30, 11:12 am, Rob Bygrave <
robin.bygr...@gmail.com> wrote:
> I don't follow this. I'd suggest you explain your question with a test case
> or full code example.
>
> On 29 May 2012 17:14, Angelo K. Huang <
angelohu...@gmail.com> wrote:
>
>
>
>
>
>
>
> > How do I specify One to Many aggregate relationship using ebean? For
> > example,
>
> > public class Class extends Model {
>
> > @OneToMany(cascade=CascadeType.PERSIST)
>
> > *private* Set< Student > students;