Hello All,
I'm using the following versions:
eclipse 3.1
postgresql 8.1.4
hibernate 3.1.3
to run this code:
............. start of code snip ...............
Session session = loginDAO.getSession(); // using hibernate synchronizer with dao objects
Login login = null;
Criteria addressbookLoginCriteria = session.createCriteria(Login.class)
.add(
Restrictions.like("Loginname", oldAddressbookLogin
.getLoginName())).add(
Restrictions.like("Loginpassword", oldAddressbookLogin
.getLoginPassword()));
List loginList = addressbookLoginCriteria.list();
Iterator iter = loginList.iterator();
while (iter.hasNext()) {
System.out.println("one result iterated");
login = (Login) iter.next();
login.setLoginname("tom");
login.setLoginpassword("riddle");
session.saveOrUpdate(login);
}
session.close();
........ end of code snip ...........
High verbosity debug and log in POSTGRESQL is on.
When I run this code, I do get proper selects from the database, which yield a loginname of justin and a password of changeme. But the code should change the name to tom and the password to riddle AND IT SHOULD PERSIST IN THE DATABASE.
If I print out the login objects loginname and password, they have changed to tom and riddle, but the data in POSTGRESQL DOES NOT CHANGE.
As you can see in my code, I have used DAO objects generated by Hibernate Synchronizer to automatically manage sessions. But I have also changed the code to manage sessions manually and the result is exactly the same.
Additionally, I have created a database on another PostgresQL server which is known to work, and the result is still the same.
My ECLIPSE console output is:
............ begin eclipse output ..................
Hibernate: select this_.loginid as loginid1_0_, this_.loginname as loginname1_0_, this_.loginpassword as loginpas3_1_0_ from login this_ where this_.loginname like ? and this_.loginpassword like ?
10:23:33,231 WARN JDBCExceptionReporter:48 - SQL Warning: 0, SQLState: 00000
10:23:33,231 WARN JDBCExceptionReporter:49 - InitPostgres
10:23:33,231 WARN JDBCExceptionReporter:48 - SQL Warning: 0, SQLState: 00000
10:23:33,231 WARN JDBCExceptionReporter:49 - StartTransaction
10:23:33,231 WARN JDBCExceptionReporter:48 - SQL Warning: 0, SQLState: 00000
10:23:33,231 WARN JDBCExceptionReporter:49 - name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 3133/1/0, nestlvl: 1, children: <>
10:23:33,231 WARN JDBCExceptionReporter:48 - SQL Warning: 0, SQLState: 00000
10:23:33,231 WARN JDBCExceptionReporter:49 - CommitTransaction
10:23:33,231 WARN JDBCExceptionReporter:48 - SQL Warning: 0, SQLState: 00000
10:23:33,231 WARN JDBCExceptionReporter:49 - name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 3133/1/0, nestlvl: 1, children: <>
Hibernate: select this_.loginid as loginid1_0_, this_.loginname as loginname1_0_, this_.loginpassword as loginpas3_1_0_ from login this_ where this_.loginname like ? and this_.loginpassword like ?
one result iterated
Hibernate: update login set loginname=?, loginpassword=? where loginid=?
Hibernate: select this_.loginid as loginid1_0_, this_.loginname as loginname1_0_, this_.loginpassword as loginpas3_1_0_ from login this_ where this_.loginname like ? and this_.loginpassword like ?
............ end of eclipse output .....................
My postgresql log of the session is:
(please note that I do run one select prior to what the code snip accounts for)
........... begin of postgresql log ...............
DEBUG: forked new backend, pid=3305 socket=8
DEBUG: postmaster child[3305]: starting with (
DEBUG: postgres
DEBUG: -v196608
DEBUG: -p
DEBUG: justin_ab
DEBUG: )
DEBUG: InitPostgres
DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 3140/1/0, nestlvl: 1, children: <>
DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 3140/1/0, nestlvl: 1, children: <>
LOG: statement: PREPARE S_1 AS BEGIN
DEBUG: StartTransactionCommand
DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 3141/1/0, nestlvl: 1, children: <>
LOG: statement: <BIND>
LOG: statement: EXECUTE <unnamed> [PREPARE: BEGIN]
DEBUG: ProcessUtility
DEBUG: CommitTransactionCommand
LOG: statement: PREPARE <unnamed> AS select this_.loginid as loginid1_0_, this_.loginname as loginname1_0_, this_.loginpassword as loginpas3_1_0_ from login this_ where this_.loginname like $1 and this_.loginpassword like $2
DEBUG: StartTransactionCommand
LOG: statement: <BIND>
LOG: statement: EXECUTE <unnamed> [PREPARE: select this_.loginid as loginid1_0_, this_.loginname as loginname1_0_, this_.loginpassword as loginpas3_1_0_ from login this_ where this_.loginname like $1 and this_.loginpassword like $2]
DEBUG: CommitTransactionCommand
LOG: statement: PREPARE <unnamed> AS select this_.loginid as loginid1_0_, this_.loginname as loginname1_0_, this_.loginpassword as loginpas3_1_0_ from login this_ where this_.loginname like $1 and this_.loginpassword like $2
DEBUG: StartTransactionCommand
LOG: statement: <BIND>
LOG: statement: EXECUTE <unnamed> [PREPARE: select this_.loginid as loginid1_0_, this_.loginname as loginname1_0_, this_.loginpassword as loginpas3_1_0_ from login this_ where this_.loginname like $1 and this_.loginpassword like $2]
DEBUG: CommitTransactionCommand
LOG: statement: PREPARE <unnamed> AS update login set loginname=$1, loginpassword=$2 where loginid=$3
DEBUG: StartTransactionCommand
LOG: statement: <BIND>
LOG: statement: EXECUTE <unnamed> [PREPARE: update login set loginname=$1, loginpassword=$2 where loginid=$3]
DEBUG: ProcessQuery
DEBUG: CommitTransactionCommand
LOG: statement: PREPARE <unnamed> AS select this_.loginid as loginid1_0_, this_.loginname as loginname1_0_, this_.loginpassword as loginpas3_1_0_ from login this_ where this_.loginname like $1 and this_.loginpassword like $2
DEBUG: StartTransactionCommand
LOG: statement: <BIND>
LOG: statement: EXECUTE <unnamed> [PREPARE: select this_.loginid as loginid1_0_, this_.loginname as loginname1_0_, this_.loginpassword as loginpas3_1_0_ from login this_ where this_.loginname like $1 and this_.loginpassword like $2]
DEBUG: CommitTransactionCommand
LOG: could not receive data from client: Connection reset by peer
LOG: unexpected EOF on client connection
DEBUG: proc_exit(0)
DEBUG: shmem_exit(0)
DEBUG: exit(0)
DEBUG: reaping dead processes
DEBUG: server process (PID 3305) exited with exit code 0
........... end of postgresql log ..........
Can anyone explain why this is happening?
Justin
|