Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can write data but can't read data from database

 
Juan Acv
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody:

I added a ServletContextListener to my struts 2 application, where I do a crud against a mysql database.

This ServletContextListener recover a bean from the applicationContext.xml, a manager to access to database, and store some data realted to the user who is logging if this data doesn't exits, so i read and check if this data exists.

I write this finder:

The listener:



The manager:




The finder:


My problem is, when there is some data associated to a user, it does't recover anything, said that the list is empty, and overwrite the data with the default parameters.

When the application is in, after logging, there is no problem recovering the data.

What I am doing wrong?

Thank you.
 
suraj savaratkar
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are retriving one row from table then use "session.load(args0,args1)" for retriving a according row from database.
 
Juan Acv
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you give me an example, please?

I used to recover a list, i am not very skilled on hibernate.

P.D. I am not using the key of the table, i am using a unique field, a "foreign key",
 
Juan Acv
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, i am stupid.

I have the option "create table if doesn't exits" on, and it overwrite all the data with the default data...

Thanks for your tip.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic