Q: JPA merge entity - from web restful jackson serialized entity The project is using springmvc building the restful service, and JPA persist data into DB.
I am recently working on update one object through web interface, i use jackson to deserialize post json data into object class. However, I have problem to merge object back to database.
I sort of knew the object class deserialized from jackson is unmanaged, that is the reason I merge is nothing happen.
Here is the sample code.
Entity:
@Entity
@Table(name="Parent")
public class Parent{

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@JsonView(JsView.Public.class)
@Column(name = "id")
private Long Id;

@NotNull
@JsonView(JsView.Public.class)
private String name;

@NotNull
@JsonView(JsView.Public.class)
private String description;

@NotNull
@ManyToOne(fetch= FetchType.LAZY, cascade = {CascadeType.REFRESH})
@JoinColumn(name="creator_id")
@JsonView(JsView.Internal.class)
private User creator;

@OneToMany(mappedBy="quest", cascade = {CascadeType.REFRESH}, orphanRemoval = true)
private List<Collaboration> collaborators = new ArrayList<Collaboration>();

}
Restful Controller:
  @RequestMapping(value = "/parent/{id}/update", method = RequestMethod.PUT)
  public ResponseEntity<String> updateQuestAttribute(@RequestBody String    parentJson,@PathVariable("id") long parent_id) {
  ObjectMapper mapper = new ObjectMapper();
  Parent parent = null;
  Parent newParent = mapper.readValue(parentJson, Parent.class);
  updateParent = parentService.updateParent(questNew,parent_id);

Service layer:
@PersistenceContext
private EntityManager entityMgr;
@Transactional
public Parent updateParent(Parent newp, long id){
    Parent old = findOne(id);
    Parent update = entityMgr.merge(newp);
    return  update;
}

I have tested this method with some managed object in Junit, all went fine. So, I guess all entity merge code is find in normal situation. Can anybody advise me what the problem is? thanks
