Java. Lang. classcastexception: Java. Lang. Short cannot be [object]

Source: Internet
Author: User

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!

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.