hibernate - bi-directional in test_data.yml -


if have code

@entity public class category extends model {      public string title;      public category() {}      public category(string title) {         this.title = title;     }      @onetomany(cascade = cascadetype.all, fetch = fetchtype.eager)     @joincolumn(name="parent")     public list<category> children = new linkedlist<category>();      @manytoone     @joincolumn(name="parent", insertable=false, updatable=false)     public category parent;      public void addchild(category child) {         category root = this;         child.parent = root;         root.children.add(child);         root.save();     } } 

and want create test data in test_data.yml file how can type there? mean bi-directional..

for example if this:

 category(root1):    title: root    children: [child1, child2]   category(child1):    title: child1    parent: root1   category(child2):    title: child2    parent: root1 

i error:

cannot load fixture initial-data.yml: no previous reference found object of type children key child1

but if not type this: children: [child1, child2] have wrong structure, child1 , child2 not ref root.

i have done similar things on similar model:

category(cat5):   title: cameras & photo category(cat5.1): {title: digital camera, parent: cat5} 

it works long use yaml data bootstrapping. because, parent reference set , child list of parent category remains uninitialized. in hibernate works because foreign key set correctly whatsoever. it's not pretty works me. have yet figure out how deal forward declarations in yaml.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -