• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts2

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Payment table

Name Month Food Milk Education Rent
Abc January 1000 110 1000 550
Abc February 1000 210 1000 100

Please help me I have a problem .i am taking the table Payment table in this table Name and Month are primary keys.using Name we get the list objects it has a problem.



We are passing the String name=abc;



Dao Class:




public final List detailsrevised(final String name) {

String s = "select d.Month from Payment d"
+ " where d.name= '" + name + "'";
Query queryResult = session.createQuery(s);

List listmonth = queryResult.list();

int lenmonth = listmonth.size();
List<Payment> PaymentList = new ArrayList<Payment>();
System.out.println(PaymentList);

for (int i = 0; i < lenmonth; i++) {
String month = (String) listmonth.get(i);
System.out.println(month);

String s1 = "select d from Payment d where d.name = '"
+ name + "' and d.Month = '" + month + "'";
Query queryResult1 = session.createQuery(s1);

Payment Payment = (Payment) queryResult1.list().get(0);

PaymentList.add(Payment);
System.out.println(i);
System.out.println(PaymentList);
}

return PaymentList;
}

Problem: here we have a problem the list of objects are same values [quickstart.model.St3Details@9f784d, quickstart.model.St3Details@9f784d]


OUT PUT
[]
January
0
[quickstart.model.St3Details@9f784d]
February
1
[quickstart.model.St3Details@9f784d, quickstart.model.St3Details@9f784d]



I think it has a problem on cache.how can solve this problem please help me







 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your Payment class should have a proper overriden toString() (and hashCode() too if you use this class in collection classes which use hash code)method which returns a String representing the object in a meaningful text. This is not related to Struts or Tomcat, so might better sit in the JIG forum.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic