古月305 2023-01-26 11:25 采纳率: 66.7%
浏览 16
已结题

使用hibernate的查询方法,结果显示一串代码而不是结果怎么办

代码如下

//查询所有
    @Test
    public void test8(){
        List<Customer> list = customerDao.findAll();
        for (Customer customer:list){
            System.out.println(customer);
        }
    }

结果显示

Hibernate: select customer0_.cust_id as cust_id1_0_, customer0_.cust_address as cust_add2_0_, customer0_.cust_industry as cust_ind3_0_, customer0_.cust_level as cust_lev4_0_, customer0_.cust_name as cust_nam5_0_, customer0_.cust_phone as cust_pho6_0_, customer0_.cust_source as cust_sou7_0_ from customer customer0_
com.domain.Customer@2c750b69
com.domain.Customer@6c569caf
com.domain.Customer@29a5f924
com.domain.Customer@5f6ba085

想请问一下怎么让它能变成正常查询的结果

  • 写回答

3条回答 默认 最新

  • pzzhao 2023-01-26 12:19
    关注

    这里默认打印的是对象的地址,你需要重写custom的toString方法将其属性打印出来

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 2月3日
  • 已采纳回答 1月26日
  • 创建了问题 1月26日

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog