[英]How to get All the elements of the entity in spring-boot ?
I'm sending a GET request from angular5 to spring-boot to get all the elements of the entity Contrat below . 我正在从angular5发送一个GET请求到spring-boot,以获取实体Contrat的所有元素。
This is the entity : 这是实体:
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Contrat implements Serializable{
@Id @GeneratedValue
private Long id;
private Date dateDebut ;
private Date dateFin ;
@ManyToOne
@JoinColumn(name = "Id_Project")
@JsonBackReference(value="projet-contrat")
private Project project;
@ManyToOne
@JoinColumn(name = "Id_AppUser")
@JsonBackReference(value="appuser-contrat")
private AppUser appUser;
}
This is the repository : 这是存储库:
public interface ContratRepo extends JpaRepository<Contrat,Long> {
@Query("select from Contrat c where c.appUser = :userApp")
public Page<Contrat> chercherContrat(@Param("userApp") AppUser userApp
, Pageable pageable);
}
In Angular5 the console.log(data) returns this result for exemple: 在Angular5中,console.log(data)返回此结果,例如:
{id: 1, dateDebut: 1526083200000, dateFin: 1526083200000}
So as you can see there is not the project element (that i need in front-end) . 因此,如您所见,没有project元素(我在前端需要)。
I want to show in angular the contrat elements plus some information of the project related to . 我想以角度展示矛盾的元素以及与该项目有关的一些信息。
Any idea ? 任何想法 ?
您可以使用PagingAndSorting存储库代替jpaRepositiry来通过findAll api获取所有相关实体的详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.