Results 1 to 4 of 4

Thread: Problem with HibernateTemplate's find method

  1. #1
    Join Date
    May 2007
    Posts
    2

    Default Problem with HibernateTemplate's find method

    Hi all,
    I am using Hibernate with spring.I have got a table that has person_number as the id and person_status and effective_date as other columns.I can have two entries for the same person_number but the effective_date has to be different.
    In my app I am trying to get the status of a person with the effective_date and I am making the following call in my DAO layer:

    getHibernateTemplate.find("from PERSON where person_number = ?",person_number);

    The problem that I am facing is that it is returning a List having the same person object even though my table has to different entries for the same person number.
    Can anybody suggest me any solution for that.I guess I know the problem.Its somewhat related with the first level cache of Hibernate.But I dont know the solution.Hence please help me in this.Thanks in advance.

    raj_spring

  2. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    I'm not sure I understand your problem. You receive a List of what?? Your person table can contain the same IDs and you retrieve multiple items, isn't that expected?

  3. #3
    Join Date
    May 2007
    Posts
    2

    Default

    Thanx for the reply.In more details,I have Person Pojo which is made to hold the information of a person from the Person_table.The identifier or the "id" is the person_number.I am trying to get information from the person_table with the Person_number and I am making a getHibernateTemplate().find("from Person where person_number = ?",personNumber).Ideally this should return a List containing Person objects.And it is also kind of doing the same thing but instead of returning a list containing different person objects,having the same personNumber,it is returning a list contaning the same object.For example lets say there are two entries in the DB with the personNumber as "1234" but the columns "effective_date" and "person_status" hold different values.The list that I am getting has the size two but contains objects which have the same information not the different ones.Now thats kind of problem that I am entangled into.
    Hope I have made my problem clear.
    Thanks again.
    raj_spring

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Ok, it would be useful to see the HBM mapping file or the POJO if you are using annotations.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •