Google App Engine java will replace jpa @ OneToMany / @ ManyToOne with objectification

I have an existing java application for Google applications that starts with jpa, and now I'm trying to switch to objectification for different purposes.

The current application has the following representation of objects.

Class Parent{
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Key key;

    @OneToMany(cascade=CascadeType.ALL, mappedBy="parent")
    private List<Child> childs = null;
}

Class Child{
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Key key;

    @ManyToOne  
    private Parent parent;

}

How can I get the above view in Objectify? I am using objectify4.
I saw @Parent, but it is not possible to load the list of child objects directly when retrieving the parent?

Thank,

Ramesh.V

+5
source share
2 answers

I found a solution for my own problem. Here is the code.

https://github.com/rameshv1210/objectify-many-to-one/

+1
source

Objectify concepts, ORM. Key . Objectify . @Parent - 1: n n: m.

,

class Parent {
    Key<Child>[] childs;
}

class Child {
    Key<Parent> parent;
}

Objectfy, .

Parent aParent = ofy.get(aChild.parent);

. , .

+2

All Articles