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