Solution for Java. Lang. illegalargumentexception: ID to load is required for loading

Source: Internet
Author: User

When Hibernate is used for relationship ing, for example, a one-to-many relationship, a test project corresponds to multiple test case modules, and some relationship ing tables:

 

Code

  <  Allow-to-one  Name  = "Testproject"  Class  = "Com. eyely. pojos. testproject"  >  
< Column Name = "F_test_project_id" SQL-type = "Nvarchar2 (32 )" />
</ Allow-to-one >


< Set Name = "Testcasemodules" Lazy = "True" Inverse = "False" >
< Key >
< Column Name = "F_test_project_id" SQL-type = "Nvarchar2 (32 )" />
</ Key >
< One-to-least Class = "Com. eyely. pojos. testcasemodule" />
</ Set >

 

Related java files:

Code

  //  Related attributes  
Private String name;
Private String description;
Private Testcasemodule parent;
Private Testproject;
/ ** It does not belong to the same Java file. For convenience, it is written together */
Testcasemodule. setdescription (CMD. getparameter ( " Description " ));
Testcasemodule. setname (CMD. getparameter ( " Name " ));
Testcasemodule. setparent (testcasemodule) Session. Get (testcasemodule. Class , Cmd. getparameter ( " Parent " )));
Testcasemodule. settestproject (testproject) Session. Get (testproject. Class , Cmd. getparameter ( " Testproject " )));

Add operation: *. jsp

Code

  // Only partCodeThe Code section has been encapsulated and is for reference only.  
Testcasemoduleprocessor Processor = Server. getprocessor (testcasemoduleprocessor. Class );

Command cmd = New Httpservletcommand (request, response );
// Todo: Miss validate.
Processor. Create (CMD );

If you access *. when adding a JSP file, the system first searches for the ID of the test project in the association relationship and obtains the ID before adding the file. If the ID of the test project cannot be obtained, an exception occurs, such as the following information:

Java. Lang. illegalargumentexception: ID to load is required for loading
Org. hibernate. event. loadevent. <init> (loadevent. Java: 51)
Org. hibernate. event. loadevent. <init> (loadevent. Java: 33)
Org. hibernate. impl. sessionimpl. Get (sessionimpl. Java: 812)
Org. hibernate. impl. sessionimpl. Get (sessionimpl. Java: 808)
Com. zyeeda. projs. cmsz. processors. testcasemoduleprocessor. Create (testcasemoduleprocessor. Java: 56)
Org. Apache. jsp. test_005fcase_005fmodule.create_jsp. _ jspservice (create_jsp.java: 81)
Org. Apache. Jasper. runtime. httpjspbase. Service (httpjspbase. Java: 70)
Javax. servlet. http. httpservlet. Service (httpservlet. Java: 717)
Org. Apache. Jasper. servlet. jspservletwrapper. Service (jspservletwrapper. Java: 377)
Org. Apache. Jasper. servlet. jspservlet. servicejspfile (jspservlet. Java: 313)

If you want to test whether your JSP file is correct, you can pass a parameter for testing. For example, if you pass a parameter in the URL to test the path of your JSP page? Testproject = 1, so no more
Appears
 
ID to load is required for loading

If an error occurs in your JSP or other code, the browser will prompt other error messages. Then you can debug your code.

 

 

Related Article

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.