精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2003-10-13
啊,你这样都没有问题么,我用的和你一样,郁闷
我这样用后就没有问题了,好像不可以动态符值: String queryString ="select user from User as user where user.userName is null"; // String queryString = "select user from User as user where user.userName is :nam and user.password is :pass"; net.sf.hibernate.Query query = session.createQuery(queryString);; // query.setString("nam", null);; // query.setString("pass", null);; System.out.println("---- list-1--------");; for (java.util.Iterator it = query.iterate();; it.hasNext();; ); { User us = (User); it.next();; System.out.println(us.getUserID(); + " Password: " + us.getPassword(););; } System.out.println("--------------------------\r\n");; 我的是db2 还发现一个现象:输出了这些东东: ---- list-1-------- Hibernate: select user0_.LogonID as x0_0_ from db2admin.Users user0_ where (user0_.Name is null ); Hibernate: select user0_.LogonID as LogonID, user0_.EmailAddress as EmailAdd2_, user0_.LastLogon as LastLogon, user0_.Password as Password, user0_.Name as Name from db2admin.Users user0_ where user0_.LogonID=? Hibernate: select contacts0_.ID as ID__, contacts0_.ID as ID, contacts0_.EmailAddress as EmailAdd2_, contacts0_.Name as Name, contacts0_.User_ID as User_ID from db2admin.Contacts contacts0_ where contacts0_.User_ID=? Hibernate: select user0_.LogonID as LogonID, user0_.EmailAddress as EmailAdd2_, user0_.LastLogon as LastLogon, user0_.Password as Password, user0_.Name as Name from db2admin.Users user0_ where user0_.LogonID=? Hibernate: select contacts0_.ID as ID__, contacts0_.ID as ID, contacts0_.EmailAddress as EmailAdd2_, contacts0_.Name as Name, contacts0_.User_ID as User_ID from db2admin.Contacts contacts0_ where contacts0_.User_ID=? 用户2 Password: 22 Hibernate: select user0_.LogonID as LogonID, user0_.EmailAddress as EmailAdd2_, user0_.LastLogon as LastLogon, user0_.Password as Password, user0_.Name as Name from db2admin.Users user0_ where user0_.LogonID=? Hibernate: select contacts0_.ID as ID__, contacts0_.ID as ID, contacts0_.EmailAddress as EmailAdd2_, contacts0_.Name as Name, contacts0_.User_ID as User_ID from db2admin.Contacts contacts0_ where contacts0_.User_ID=? younhu Password: 22 43 Password: null -------------------------- 为啥查询出的3条纪录不是写在一块的。而是分开写的,先打出一条,再打出2条来,奇怪的紧 |
|
返回顶楼 | |