0

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
4

1 回答 1

1

1)创建你的图表

2)使用SnakeYAML序列化对象:

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

3)查看结果并手动更改。

PS !models.Role 是一个本地标签,你应该指导 SnakeYAML 如何管理它。

于 2010-07-21T16:43:38.643 回答