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.