• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Can write data but can't read data from database

 
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.
 
Ranch Hand
Posts: 104
  • 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.
 
Self destruct mode activated. Instructions for deactivation encoded in this tiny ad.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic