java - "No row with the given identifier exists" although it DOES exist -


I use the exception in hibernate and getting

thread "main" org.hibernate I am doing ObjectNotFoundException: No row exists with the given identifier: [# 271]

What is so strange about this error, that the object of the given ID is present in the database Put the problematic record in the second part of the application. If I look at it in the same running (like the same hibernate session), then there is no problem retrieving the data.

Just because it can be a mapping mistake:

  public class issue class applies {@ManyToOne (optional = false) Private MyDbObject myDbObject; } Public class MyDbObject is being implemented Persistent {@OneToMany (mapped = "myDbObject") Private list & lt; Problem class & gt; ProblemClasses; @ManyToOne (optional = false) Private third class III class; }  

I have no complete clue where to pay attention also. Any indication highly appreciated!

Just to clarify: The data was inserted in the second part of the application. This is definitely in the database because I can see it after a SQL query through the end. And after that, that means when I start the application again, I get an error in the first query of the database - no extinction, no rollback is included.

Addition: Because it was asked, here is the code to get the data:

public list & lt; Problem class & gt; GetProbblClasses () {Query Query = Sessions .createQuery ("From ProblemClass"); Return query.list (); }

And to accomplish this, here is the general code to insert it (before bringing it to the second part of the application):

  public zero Save (persistent constant) {session.saveOrUpdate (continuously); }  

Eureka, I found it!

The problem was:

The data in the table third class was not correctly maintained since this data from MyDbObject

  Alternate = False  

, Hibernate is an internal insert, so returns an empty result to connect because it was implemented in one session ( I think in the cache), there was no problem in it.

MySQL does not apply to foreign key integrity, thus complaining about inserting corrupted data.

Solution: Optional = correct or correct entry of data.


Comments