So...
- have you checked the rest of your code? Are you sure this piece of
code is actually called? Step through it or add debugging output.
I don't know how else I would get the Hibernate log output:
"Hibernate: insert into room (roomType, roomNumber, smoking, active)
values (?, ?, ?, ?)"
How can I get Hibernate to show the log output with the values?
I went over the mysql logs and at the end finally found something. If
you want, you can skip directly to the place where I say "Oops"
I checked the MySQL logs and I even have the query in there...
Here are the mysql logs:
Here is my insert...
3 Prepare [7]
3 Execute [7] insert into room (roomType, roomNumber,
smoking, active) values ('PRM', '12', 'F', 'F')
Then comes the select that displayes the new list
060525 8:14:45 3 Prepare [8]
3 Execute [8] select room0_.id as id0_,
room0_.roomType as roomType0_, room0_.roomNumber as roomNumber0_,
room0_.smoking as smoking0_, room0_.active as active0_ from room room0_
The room is in the list
Then comes my mysql command line client to check the table:
060525 8:16:53 4 Connect [EMAIL PROTECTED] on rbs1
4 Query select * from room
060525 8:17:01 4 Query select * from room
And the result is "Empty set"
Now I try to insert the same record ( just with number 120 rather than
12) from the command line:
060525 8:19:36 4 Query insert into room (roomType,
roomNumber, smoking, active) values ('PRM', '120', 'F', 'F')
And another commandline select to verify:
060525 8:19:40 4 Query select * from room
It comes back with the new record (120)
Then comes Hibernate (I refresh the browser list page):
060525 8:21:00 3 Prepare [12]
3 Execute [12] select room0_.id as id0_,
room0_.roomType as roomType0_, room0_.roomNumber as roomNumber0_,
room0_.smoking as smoking0_, room0_.active as active0_ from room room0_
The result is still the old one (only room 12, not room 120)
Now I restart Tomcat...
Oops... I just found something interesting:
This was called when Tomcat shut down:
060525 8:22:48 3 Query rollback
3 Quit
This was called in the beginning when Tomcat started:
3 Query SET autocommit=1
3 Query SET autocommit=0
So Spring never executed commit, instead goes through all my web
requests on just one session and at the end calls rollback (no idea why
it doesn't commit).
So I guess this is what happens... now the question: how do I fix it?
MARK
P.S.: Here is my Hibernate configuration:
hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
hibernate.connection.driver_class=org.gjt.mm.mysql.Driver
hibernate.connection.password=password
hibernate.connection.url=jdbc:mysql://localhost/rbs1
hibernate.connection.username=rbs
hibernate.cache.provider_class = org.hibernate.cache.HashtableCacheProvider
hibernate.show_sql = true
- if you're sure your application is otherwise correct, the code gets
executed with the room object you intend it to, and you still don't
have anything in your database, I believe you have something severely
misconfigured and suggest you post your configuration.
That would be the part of your Spring applicationContext.xml (or
whatever it is called in your case) where you set up the data source
and the session factory.
some more comments...
I figured since everybody has problems with Spring closing sessions too
early and thereby causing problems with lazy-load, it should not affect
me in this case and actually work for me.
But maybe not???
Since you have no problem with lazy loading, in fact, you are not even
loading, I believe keeping the session open until the view is rendered
will not help you.
The Page gets the Service (a singleton SpringBean) via tapestry-spring
library ("spring:...").
The Service gets a DAO through Spring IoC.
Just out of curiosity: Why do you not inject your Dao into the page?
What does "the Service"? do?
So I guess the DAO is a singleton that opens a session once and never
closes it? Does that mean that everything is one session/transaction,
across all requests and user-web-sessions?
No.
hth,
Lutz
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]