How to create a custom @jsonDeserializer class in java
I have a java class. Which is related to many other java classes. and I want to deserialize this class. Please help me to deserialize the class. My class is like this..
@Entity @Table(name = "A", uniqueConstraints = @UniqueConstraint(columnNames = { "name" })) @JsonIdentityInfo(generator=ObjectIdGenerators.IntSequenceGenerator.class, property="@_refid") @JsonDeserialize(using=ADeSerializer.class) public 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
}
Saying clearly...
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
}
My rest service is
@RequestMapping(value="/saveA", method=RequestMethod.POST ) public @ResponseBody MIResponse saveA(@RequestBody A a) throws Exception{
return null;
}
链接地址: http://www.djcxy.com/p/48910.html
上一篇: 重新启动远程git分支