tags:

views:

100

answers:

1

Hello,
I use a snakeyaml (java) based parser to write a test case, and couldn't figure out how to properly build the graph. Any help, highly appreciated. thanks.

RuntimeException occured : Cannot load fixture test-data.yml: 
org.hibernate.PropertyAccessException: could not get a field value by 
reflection getter of models.Priority.description

the above exception is for an unrelated field, and it works if I remove the association

roles: 
  - roleType: testRoleType 
    description: desc 

If I change it to

- !models.Role 
      roleType:         testRoleType 
      description: desc 

RuntimeException occured : Cannot load fixture test-data.yml: null; Can't construct a java object for !models.Role; exception=onRole Any help, highly appreciated. thanks.

public class Person {
String fullname;

@OneToMany(cascade=CascadeType.ALL)
public List<Role> roles;
}

public class Role {
public RoleType roleType;
public String description;
}

public class RoleType {
public String roleName;
public String description;
}


YAML--

RoleType (testRoleType):
    roleName:      test
    description:   desc

Person(administrator):
    fullname:       Administrator
    roles:
      - roleType: testRoleType
        description: desc
+1  A: 

1) create your graph

2) Use SnakeYAML to serialize the object:

JavaBeanDumper dumper = new JavaBeanDumper();
String output = dumper.dump(graph);

3) see what comes out of it and change it manually.

P.S. !models.Role is a local tag and you should instruct SnakeYAML how to manage it.