*
The moose likes Object Relational Mapping and the fly likes Using Hibernate: getting same value 3 times Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Using Hibernate: getting same value 3 times" Watch "Using Hibernate: getting same value 3 times" New topic
Author

Using Hibernate: getting same value 3 times

Anirban D Jumy
Greenhorn

Joined: Dec 26, 2011
Posts: 3
Hi,
I am developing a small project using Hibernate where I think there was an issue with the mapping. I am using the following tools:
1. Mysql 5.x
2. Eclipse Indigo
3. JRE 7
4. Tomcat 7

Here are my files:

1. hibernate.cfg.xml



2. PojoTestTable.java




3. PojoTestTable.hbm.xml



4. DisplayData.java (Individual Servlet)





5.. in MySQL , table name is: TestTable

fields are: id int (11), fld1 varchar(10), fld2 varchar (10).


When I am running this DisplayData.java servlet, it is fetching first column value 3 times(3 rows are there in the table)...

Please look into it and give me a solution...

Thanks in advance..

Regards,
Anirban
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Could you edit your post and wrap each code with the code tag? It will be easier to read.

Welcome to Javaranch.


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Anirban D Jumy
Greenhorn

Joined: Dec 26, 2011
Posts: 3
Hi Hebert Coelho,
As per your request, I have edited the post.. Please help me in resolving this issue..

Thank you

Regards,
Anirban
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

When I am running this DisplayData.java servlet, it is fetching first column value 3 times(3 rows are there in the table)...

Can you elaborate this more? Do you get 3 objects returned to the list corresponds to the rows of the table? Or you expected something else?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Anirban D Jumy
Greenhorn

Joined: Dec 26, 2011
Posts: 3
Hi Vijitha,
Thanks for replying me.

I want the rows to be fetched from the database, not the objects.

Suppose three columns are there id, fld1, fld2
Values are there 123, aaaa, ssss//123, wwww, ddddd// 123, zzzz, rrrrr

Now when runing the program I am getting aaaa, aaaa, aaaa instead of aaaa, wwww, zzzz

Please let me know if you want to know more..

Thanks
Anirban



Vijitha Kumara wrote:
When I am running this DisplayData.java servlet, it is fetching first column value 3 times(3 rows are there in the table)...

Can you elaborate this more? Do you get 3 objects returned to the list corresponds to the rows of the table? Or you expected something else?
Ankit Nagpal
Ranch Hand

Joined: Sep 09, 2008
Posts: 47

Anirban D Jumy wrote:
Suppose three columns are there id, fld1, fld2
Values are there 123, aaaa, ssss//123, wwww, ddddd// 123, zzzz, rrrrr

Now when runing the program I am getting aaaa, aaaa, aaaa instead of aaaa, wwww, zzzz


How can the identifier have same values for 3 different records? Did you check your DB if it has the correct data in the first place?

Ankit
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Using Hibernate: getting same value 3 times
 
Similar Threads
Could not parse mapping document from resource PojoTestTable.hbm.xml
Automatic Schema Generation
hibernate exception
Session throwing NullPointerException
StaleStateException