简体   繁体   English

如何在spring-boot中获取实体的所有元素?

[英]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.

相关问题 如何在spring-boot中获取实体的所有元素? - How to get All the elements of the entity in spring-boot? 如何仅扫描一个具体的JPA实体,但不是所有实体都使用spring-boot扫描相同的软件包? - How just scan a concrete JPA entity but not all entities bellow the same package with spring-boot? 使用注释将所有返回的元素放入Spring-Boot缓存中 - Putting all returned elements into a Spring-Boot cache using annotations 如何将存储过程的结果 map 存储到 spring-boot/hibernate 中的实体 - How to map the results of a stored procedure to an entity in spring-boot/hibernate spring-boot redis:如何使用户的所有会话无效? - spring-boot redis : How to invalidate all sessions of a user? 如何使用spring-boot @Async来使用Java 8 - How to get spring-boot @Async to work with Java 8 如何以编程方式在spring-boot中获取当前的SpringApplication实例? - How to get current SpringApplication instance in spring-boot programmatically? 如何在gradle中获得spring-boot依赖版本? - How to get spring-boot dependency version in gradle? 如何在 Spring-Boot CrudRepository 中获取数组中具有值的对象列表 - How to get List of Objects with value in array in Spring-Boot CrudRepository 如何在Spring-Boot中获取属性文件的bean? - How can I get the bean of a property file in Spring-Boot?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM