为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我查询所有信息 控制台显示的只有一个对象名

三月 15, 2016 10:37:13 上午 org.hibernate.annotations.common.Version <clinit>

INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}

三月 15, 2016 10:37:13 上午 org.hibernate.Version logVersion

INFO: HHH000412: Hibernate Core {4.2.21.Final}

三月 15, 2016 10:37:13 上午 org.hibernate.cfg.Environment <clinit>

INFO: HHH000206: hibernate.properties not found

三月 15, 2016 10:37:13 上午 org.hibernate.cfg.Environment buildBytecodeProvider

INFO: HHH000021: Bytecode provider name : javassist

三月 15, 2016 10:37:13 上午 org.hibernate.cfg.Configuration configure

INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml

三月 15, 2016 10:37:13 上午 org.hibernate.cfg.Configuration getConfigurationInputStream

INFO: HHH000040: Configuration resource: /hibernate.cfg.xml

三月 15, 2016 10:37:13 上午 org.hibernate.cfg.Configuration addResource

INFO: HHH000221: Reading mappings from resource: Entity/Admin.hbm.xml

三月 15, 2016 10:37:13 上午 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity

WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!

三月 15, 2016 10:37:13 上午 org.hibernate.cfg.Configuration addResource

INFO: HHH000221: Reading mappings from resource: Entity/Buyer.hbm.xml

三月 15, 2016 10:37:13 上午 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity

WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!

三月 15, 2016 10:37:13 上午 org.hibernate.cfg.Configuration doConfigure

INFO: HHH000041: Configured SessionFactory: null

三月 15, 2016 10:37:13 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)

三月 15, 2016 10:37:13 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000115: Hibernate connection pool size: 20

三月 15, 2016 10:37:13 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000006: Autocommit mode: false

三月 15, 2016 10:37:13 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/apwm?useUnicode=true&characterEncoding=utf8]

三月 15, 2016 10:37:13 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000046: Connection properties: {user=root, password=****}

三月 15, 2016 10:37:13 上午 org.hibernate.dialect.Dialect <init>

INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect

三月 15, 2016 10:37:13 上午 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService

INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)

三月 15, 2016 10:37:13 上午 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>

INFO: HHH000397: Using ASTQueryTranslatorFactory

三月 15, 2016 10:37:14 上午 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: HHH000228: Running hbm2ddl schema update

三月 15, 2016 10:37:14 上午 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: HHH000102: Fetching database metadata

三月 15, 2016 10:37:14 上午 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: HHH000396: Updating schema

三月 15, 2016 10:37:14 上午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000261: Table found: apwm.admin

三月 15, 2016 10:37:14 上午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000037: Columns: [password, name, createdate, id, right]

三月 15, 2016 10:37:14 上午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000108: Foreign keys: []

三月 15, 2016 10:37:14 上午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000126: Indexes: [primary]

三月 15, 2016 10:37:14 上午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000261: Table found: apwm.buyer

三月 15, 2016 10:37:14 上午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000037: Columns: [password, temp, address, money, name, certificate, createdate, tel, id, credit]

三月 15, 2016 10:37:14 上午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000108: Foreign keys: []

三月 15, 2016 10:37:14 上午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000126: Indexes: [primary]

三月 15, 2016 10:37:14 上午 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: HHH000232: Schema update complete

Hibernate: 

    select

        buyer0_.id as id1_1_,

        buyer0_.name as name2_1_,

        buyer0_.password as password3_1_,

        buyer0_.money as money4_1_,

        buyer0_.tel as tel5_1_,

        buyer0_.certificate as certific6_1_,

        buyer0_.temp as temp7_1_,

        buyer0_.address as address8_1_,

        buyer0_.credit as credit9_1_,

        buyer0_.createdate as created10_1_ 

    from

        buyer buyer0_

Entity.Buyer@1b1cfb87

Entity.Buyer@446a1e84


正在回答

5 回答

你在Students.java里面加上toString方法,里面加上你的Students的参数就ok了.

0 回复 有任何疑惑可以回复我~

查询学生的时候出现只有地址的情况,是因为query.list返回的对象是Object类型是,需要我们手动将它转为Students类型,首先在StudentsDAO  将queryAllStudents的返回值改为List<Object[]>,然后在test类中书写以下代码

StudentsDAO sdao = new StudentsDAOImpl();

List<Object[]> list = sdao.queryAllStudents(); 

//转换  

List<Students> prolist = new ArrayList<Students>();  

for(int i=0; i<list.size(); i++){  

Object[] obs=list.get(i);  

Students student = new Students();  

student.setSid((String)obs[0]);  

student.setSname((String)obs[1]);  

student.setGender((String)obs[2]);  

student.setBirthday((Date)obs[3]);  

student.setAddress((String)obs[4]);  

prolist.add(student);  

}

for(int i = 0;i<prolist.size();i++){

System.out.println(prolist.get(i));

}


0 回复 有任何疑惑可以回复我~

实体类中Suorce加个toString函数

0 回复 有任何疑惑可以回复我~

没有重写toString函数,在你的实体类里加toString函数就行,返回值就是你想输出的东西。

0 回复 有任何疑惑可以回复我~
#1

萌萌滴YU祥

加了也没用
2017-02-07 回复 有任何疑惑可以回复我~

不是很懂

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为什么我查询所有信息 控制台显示的只有一个对象名

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信