Angularjs 保存实体Spring MVC时更新多个表

Angularjs 保存实体Spring MVC时更新多个表,angularjs,spring,rest,entity,multiple-tables,Angularjs,Spring,Rest,Entity,Multiple Tables,我在使用保存对数据库的引用的实体时遇到问题 Spring MVC和AngularJS 我的实体: Entity @Table(name = "comment") public class Comment { @Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name = "id", nullable = false) private Long id; @Column(name = "cr

我在使用保存对数据库的引用的实体时遇到问题 Spring MVC和AngularJS

我的实体:

Entity
@Table(name = "comment")
public class Comment {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name = "id", nullable = false)
    private Long id;

    @Column(name = "creation_date", nullable = false)
    private Date creationDate;

    @Column(name = "comment", nullable = false)
    private String comment;

    @ManyToOne
    @JoinColumn(name = "article", nullable = false)
    private Article article;

    @ManyToOne
    @JoinColumn(name = "user", nullable = false)
    private User user;
}


@Entity
@Table(name = "article")
public class Article {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", nullable = false)
    private Long id;

    @ManyToOne
    @JoinColumn(name="user", nullable=false)
    private User user;

    ...
}
如何在保存新文章的同时将新实体添加到注释表中? 如何在一个事务中执行两个更新? 我如何将来自angular的请求与控制器连接,以及它们看起来如何

角度:

$http({
    url : ..../new,
    method : POST,
    data : ?
})
@RestController

@RequestMapping(value = "/new", method = RequestMethod.POST)
public Article addArticle(@RequestBody Article article, ?) {
    article.setId(null);        
    return articleService.save(article);
    //but how to save comment?
}
谢谢大家!