如何在java中创建自定义的@jsonDeserializer类

时间:2013-08-26 07:47:38

标签: java json rest

我有一个java类。这与许多其他java类有关。 我想反序列化这个类。请帮我反序列化。   我的班级是这样的..

@Entity @Table(name =“A”,uniqueConstraints = @UniqueConstraint(columnNames = {“name”})) @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class,property =“@_ refid”) @JsonDeserialize(使用= ADeSerializer.class) 公共等级A {

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

@Column(name = "DESCRIPTION")
private String description;

//

@ManyToMany(cascade={CascadeType.REMOVE, CascadeType.MERGE},fetch=FetchType.EAGER)
@JoinTable(
        name="B",
        joinColumns={@JoinColumn(name="Aname")},
        inverseJoinColumns={@JoinColumn(name="Bname", unique=true)}
    )
@Fetch(FetchMode.SUBSELECT)
private Set<C> cs;

@ManyToMany(cascade={CascadeType.MERGE},fetch=FetchType.EAGER)
@JoinTable(
        name="D",
        joinColumns=@JoinColumn(name="Aname"),
        inverseJoinColumns=@JoinColumn(name="Ename")
    )
@Fetch(FetchMode.SUBSELECT)
private Set<E> Es;

@Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
@ManyToMany(cascade={CascadeType.ALL, CascadeType.MERGE},fetch=FetchType.EAGER)
@JoinTable(
        name="F",
        joinColumns=@JoinColumn(name="Aname"),
        inverseJoinColumns=@JoinColumn(name="Fname")
    )
@Fetch(FetchMode.SUBSELECT)
private Set<F> Fs;



// Getters and setters

}

清楚地说......

 Class A {
        Object of Class B;
        Object of Class C {
                  Set<ClassB> bs;
               Objects of Class C;
               Object of Class A
          }
       other local variables;

      Objects of Class D{
             set<ClassB> ds;
        }

// Getters and setters

}

我的休息服务是

@RequestMapping(value =“/ saveA”,method = RequestMethod.POST)     public @ResponseBody MIResponse saveA(@RequestBody A a)抛出异常{

    return null;
}

0 个答案:

没有答案