getting parent's data from @ManyToOne

164 views
Skip to first unread message

SergPro

unread,
May 14, 2012, 4:25:02 PM5/14/12
to eb...@googlegroups.com
I'm not getting parent's field data when perform the following, see model below.

somewhere() {
  Child child = Ebean.find(Child.class, 1);
  Logger.info(child.parent.name); << -------NULL
}

@Entity
@Table(name="Parent")
public class Parent  extends Model {
@Id
@Column(name = "parent_id")
public Integer id;

@Column(name = "name")
public String name;

@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "parent")
public List<Product> children;
}

@Entity
@Table(name="Child")
public class Child  extends Model {
@Id
@Column(name = "child_id")
public Integer id;

@ManyToOne
@JoinColumn(name="parent_id")
     public Parent parent;
public String description;
}

Rob Bygrave

unread,
May 14, 2012, 5:31:03 PM5/14/12
to eb...@googlegroups.com

SergPro

unread,
May 15, 2012, 9:40:40 PM5/15/12
to eb...@googlegroups.com
Rob,
This is it! Made the change in the Build.scala and it is working now.
Thanks for your help!
Reply all
Reply to author
Forward
0 new messages