為什么我查詢所有信息 控制臺顯示的只有一個對象名
三月 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
2017-08-03
你在Students.java里面加上toString方法,里面加上你的Students的參數(shù)就ok了.
2017-02-27
查詢學生的時候出現(xiàn)只有地址的情況,是因為query.list返回的對象是Object類型是,需要我們手動將它轉(zhuǎn)為Students類型,首先在StudentsDAO ?將queryAllStudents的返回值改為List<Object[]>,然后在test類中書寫以下代碼
StudentsDAO sdao = new StudentsDAOImpl();
List<Object[]> list = sdao.queryAllStudents();?
//轉(zhuǎn)換 ?
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));
}
2016-05-02
實體類中Suorce加個toString函數(shù)
2016-03-28
沒有重寫toString函數(shù),在你的實體類里加toString函數(shù)就行,返回值就是你想輸出的東西。
2016-03-17
不是很懂