[Hibernate] Quick Solution for org. hibernate. objectnotfoundexception: no row with the given identifier exists

Source: Internet
Author: User

Recently, the system encountered such a problem. I Googled it online and the result was a data problem.
Console error printing:
Severe: servlet. Service () for servlet default threw exception
Org. hibernate. objectnotfoundexception: no row with the given identifier exists: [COM. ISS. Fit. Po. system. sysdepartment #361]
At org. hibernate. impl. sessionfactoryimpl $1. handleentitynotfound (sessionfactoryimpl. Java: 377)
At org. hibernate. event. Def. defaultloadeventlistener. Load (defaultloadeventlistener. Java: 145)
At org. hibernate. event. Def. defaultloadeventlistener. proxyorload (defaloadloadeventlistener. Java: 179)
At org. hibernate. event. Def. defaultloadeventlistener. onload (defaultloadeventlistener. Java: 103)
At org. hibernate. impl. sessionimpl. fireload (sessionimpl. Java: 878)
At org. hibernate. impl. sessionimpl. internalload (sessionimpl. Java: 846)
At org. hibernate. type. entitytype. resolveidentifier (entitytype. Java: 557)
At org. hibernate. type. entitytype. Resolve (entitytype. Java: 379)
This problem has been clearly stated in other blogs because the foreign keys of other tables are associated with the primary keys of this table.
Reference from other forums:
Assume that table 1 has its own primary key id1 and table 2's primary key Id2.
If the hibenrate is set to a single association, even if Id2 in Table1 is null and Id2 in Table2 has a value, no query error will occur. however, if the Id2 field in Table 1 has a value but this value does not exist in the primary key value in table 2, the above error will be reported!
If Hibernate is a bidirectional Association, Id2 in Table1 is null, but if there is a value in Table2, this error is reported. in this case, the current solution is to change to a single association, or change the corresponding data!
The quickest solution to this problem is to add the value corresponding to the table field in the database. For example, if this error occurs, the primary key ID of sysdepartment is referenced and the primary key of sysdepartment is increased to 361,.
However, this method is only for the time being and must be modified in the program.
The posts posted from this forum can be used as reference:
Http://blog.csdn.net/hotdogcug/archive/2008/03/24/2212032.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.