【问题标题】:What will be the query to fetch the order id of a particular order from a database从数据库中获取特定订单的订单 ID 的查询是什么
【发布时间】:2020-03-18 05:10:21
【问题描述】:

从数据库中获取特定 Goal_name 的 Goal_id 的查询是什么假设一列是 Goal_id,另一列是 Goal_nameenter image description here。我希望它采用以下格式(本机查询)

@Query("Select a from UserEntity a where a.userId= :userId")    
List<UserEntity> getUserById(@Param("userId") String userId);

我想在 Spring Boot 中使用它,我将从 UI 获取订单号,我想获取该订单号的相应订单 ID

【问题讨论】:

标签: mysql sql database spring-boot spring-data-jpa


【解决方案1】:

如果您有 userNumber 属性,您的返回响应必须类似于 UserEntity.getUserNumber()。

【讨论】:

    【解决方案2】:

    类似的东西。 详细信息可能会有所不同,具体取决于您的实体的确切设计以及您是否期望 1、0-1 或 N 个结果以及是否需要 ListSet

    @Query("SELECT a.goalId FROM UserEntity a where a.goalName = :name")
    List<Long> getIdsForName(String name)
    

    【讨论】:

      猜你喜欢
      • 2017-08-05
      • 2017-08-26
      • 2021-10-10
      • 1970-01-01
      • 2021-07-14
      • 1970-01-01
      • 2013-04-15
      • 2020-05-08
      • 1970-01-01
      相关资源
      最近更新 更多