【问题标题】:findAll returns empty listfindAll 返回空列表
【发布时间】:2020-06-06 10:33:55
【问题描述】:

这是存储库界面

@Repository
    public interface MenuStructureTblService extends JpaRepository<MenuStructureTbl, Integer> {
}

MenuStructureTbl 表

@Data
@Entity(name = "menu_structure_tbl")
public class MenuStructureTbl {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    Integer menuId;
    public String menuTitle;
    public String menuText;
    public Integer menuMotherId;
    public String createDate;
    public String updateDate;
}

我正用头撞墙,退货清单是空的。

这个返回null

@Repository
public interface MenuStructureTblService extends JpaRepository<MenuStructureTbl, Integer> {
    @Query(value="SELECT * FROM menu_structure_tbl", nativeQuery = true)
    Object justGetIT();
}

返回空值;我检查了查询,生成了结果。但是,我不知道发生了什么事。

如果您有任何问题,请告诉我。

【问题讨论】:

  • 您的预期结果是什么?您的表中是否有一些行没有被 findAll 找到?
  • @RolandWeisleder,我有数据
  • 正在使用 findAll() 并获得空列表,或者您没有获得 justGetIT() 的记录,您可以将返回类型从 Object 更改为用于 justGetIT 方法的 MenuStructureTbl
  • 可能相关:尝试将@Entity(name = "menu_structure_tbl")更改为@Entity @Table(name = "menu_structure_tbl")
  • 我也试过了。 @Roland 它没有用。我也没提。

标签: mysql spring-boot jpa


【解决方案1】:

我的错误,环境冲突,我正在检查错误的环境。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-15
    • 2021-06-27
    相关资源
    最近更新 更多