aspose file tools*
The moose likes Tomcat and the fly likes struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "struts2" Watch "struts2" New topic
Author

struts2

guntur reddy
Greenhorn

Joined: Jan 23, 2011
Posts: 9
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







Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

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.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts2