Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

struts2  RSS feed

guntur reddy
Posts: 9
  • Mark post as helpful
  • send pies
  • 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 '" + name + "'";
Query queryResult = session.createQuery(s);

List listmonth = queryResult.list();

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

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

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

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


return PaymentList;

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

[quickstart.model.St3Details@9f784d, quickstart.model.St3Details@9f784d]

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

Vijitha Kumara
Saloon Keeper
Posts: 3997
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • 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.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!