Wednesday, 23 May 2012

Hibernate retrieve the first record always when we try retrieve all records

 

Today I come across a very strange behavior with hibernate while I am trying to retrieve all the records.

Here is that

1. Go to my Hibernate Introduction Part 4 Post

2. In the Patient.Java bean class, you can see the following lines

@Id
@GeneratedValue
@Column(name="ID")
public Integer getId() {
    return id;
}

Assume that we misspelled the Column name id as RowID (this may happen when we cut and paste code from different project/examples)

Now it will look like

@Id
@GeneratedValue
@Column(name="RowID")
public Integer getId() {
    return id;
}

 

Now go to Test.Java and comment all the methods except getallRecords()

Now run the application

You can observer that first record is repeated up to total records in the table.

 

No comments:

Post a Comment