Exception:
Java. Lang. classcastexception: Java. Lang. Short cannot be cast to org. hr. entity. salarystandarddetails
At org. hr. Dao. impl. salarystandardcheckindaoimpl. addsalarystandardetails (salarystandardcheckindaoimpl. Java: 41)
At sun. Reflect. nativemethodaccessorimpl. invoke0 (native method)
Code:
DAO implementation class:
/**
* Registration of basic compensation standard information
*/
Public salarystandard addsalarystandard (salarystandard alarystandard ){
Salarystandard Ss = (salarystandard) Super. gethibernatetemplate (). Save (alarystandard );
Return SS;
}
Action:
/**
* Add salary standard registration records
*
* @ Param Mapping
* @ Param form
* @ Param request
* @ Param response
* @ Return
* @ Throws exception
*/
Public actionforward dosalarycheckin (actionmapping mapping,
Actionform form, httpservletrequest request,
Httpservletresponse response) throws exception {
Salarystandardcheckinform SSCI = (salarystandardcheckinform) form; // obtain formbean
// Create a compensation entity class
Salarystandarddetails SSD = new salarystandarddetails (); // pay standard ticket details
Salarystandard Ss = new salarystandard (); // basic salary standard information
String sdid = SSCI. getss (). getstandardid (); // Salary Standard Ticket No.
String sdname = SSCI. getss (). getstandardname (); // pay standard ticket name
Short sditemid = SSCI. getssd (). getitemid (); // salary Project No.
// Assign the value in the detailed information of the salary standard ticket to the salary details
SSD. setstandardid (sdid );
SSD. setstandardname (sdname );
SSD. setitemid (sditemid );
SSD. setitemname (SSCI. getssd (). getitemname ());
SSD. setsalary (SSCI. getssd (). getsalary ());
// Beanutils. copyproperties (SSD, SSCI. getssd ());
// Assign the value of basic salary information to basic salary information
SS. setchecktime (new date ());
Beanutils. copyproperties (SS, SSCI. getss ());
Salarystandarddetails ssde = salarystandardcheckinbiz. addsalarystandardetails (SSD); // Add compensation details
Salarystandard sasd = salarystandardcheckinbiz. addsalarystandard (SS); // Add basic salary standard information
Request. setattribute ("salarystandarddetails", ssde );
Request. setattribute ("salarystandard", sasd );
Return Mapping. findforward ("salarystandardrecheck ");
}
Entity class:
Private short sdtid; // ID
Private string standardid; // Salary Standard Ticket No.
Private string standardname; // standard compensation name
Private short Itemid; // Number of the compensation item
Private string itemname; // The Name Of The compensation project.
Private double salary; // compensation amount
The first ID increases automatically. It has nothing to do with it, that is, the Itemid. But when I assign values, it is of the short type. How can I prompt that it cannot be converted to org. HR. entity. what about salarystandard?
Solution:
Super. gethibernatetemplate (). Save (alarystandard); the object cannot be returned and it returns void
Solve the problem!