英文:
data not getting fetched from database using hibernate in correct format
问题
我想使用Hibernate HQL从数据库中获取学生数据列表,但在运行代码后,数据没有以正确的形式获取,而是返回了其他内容,并且没有出现错误。
以下是附加的代码和输出:
英文:
i want to fetch a list of student data from database using hibernate HQL but after running the code data is not getting fetched in correct form and instead returning something else and there are no errors.
Here is the attached code and output
答案1
得分: 0
你正在执行:
System.out.println(s);
Student
类没有重写toString()
方法,因此你看到的是Java默认的toString()
方法,它会打印类名和引用。
你必须在Student
类中实现toString()
方法以查看其他信息。
英文:
You are doing:
System.out.println(s);
Student
has not overridden toString()
method therefore you see the Java default toString()
method that prints the class name and the reference.
You must implement toString()
on the Student
class to see anything else.
专注分享java语言的经验与见解,让所有开发者获益!
评论