This week's book giveaway is in the Java in General forum.
We're giving away four copies of 97 Things Every Java Programmer Should Know and have Kevlin Henney & Trisha Gee on-line!
See this thread for details.
Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Error: Data Access Failure

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I got a strange error. The message given to me is as follows.

Data Access Failure

More than one row with the given identifier was found: 1, for class: com.trailsindia.innform.model.TransactionDetails; nested exception is org.hibernate.HibernateException: More than one row with the given identifier was found: 1, for class: com.trailsindia.innform.model.TransactionDetails

The server displays as follows....
[clubone] WARN [btpool0-1] LoadContexts.cleanup(108) | fail-safe cleanup (collections) : org.hibernate.engine.loading.CollectionLoadContext@1dd5c52<rs=org.apache.commons.dbcp.DelegatingResultSet@6edb>
[clubone] WARN [btpool0-1] CollectionLoadContext.cleanup(332) | On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [2] entries

The transactionDetails table is shown below....

mysql> select * from transaction_details;
+----+-----------+----------+----------------+-------------+--------+-------------+-------------------+--------------------+----------+--------------------+-----------+
| id | cv_number | cv_value | expired_points | expiry_date | points | earned_date | redumption_points | trans_remarks | hotel_id | points_earned_type | member_id |
+----+-----------+----------+----------------+-------------+--------+-------------+-------------------+--------------------+----------+--------------------+-----------+
| 1 | NULL | NULL | 0 | 2012-03-02 | 100 | 2009-03-02 | 0 | Enrollement Points | 1 | 1 | 1 |
| 2 | NULL | NULL | 0 | 2012-03-02 | 100 | 2009-03-02 | 0 | Enrollement Points | 1 | 1 | 2 |
+----+-----------+----------+----------------+-------------+--------+-------------+-------------------+--------------------+----------+--------------------+-----------+
2 rows in set (0.00 sec)


Does anyone Knows what error I have got???

Thanks in advance.

Philip
 
author and cow tipper
Posts: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the error is pretty self-explanatory - Hibernate sees two different rows or record with the same primary key. How that error happened can be tricky.

How has your table defined the primary key in the XML file? Is it a compound key? Often a compound or surrogate key defined in the xml or annotation, that is not backed up or constrained at the database level, will trigger this type of exception.

This happens only on selects? Nobody is creating any rows during this operation while manually creating a primary key for the record in their code?

-Cameron McKenzie


 
Philip Zac
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to Cameron McKenzie,

I just found the error. It is due to wrong mapping relationship (OneTo one) It must be (OneToMany or ManyToOne) relationship.

Anyway, thanks.

Philip
 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sometimes the most obvious of errors are the hardest to spot. I'm glad the problem is solved and it's finally working.

Happy Hibernating!

-Cameron McKenzie
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I googled for that error/warning, so I got here. Mine was more obvious, instead of

it should be

thanks for this post
 
I can't renounce my name. It's on all my stationery! And hinted in this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic