无法强制转换为java.lang.String异常

时间:2022-11-07 22:42:51
@Entity
@Table(name = "RateTransmissionDetails")
public class RateTransmissionDetails implements java.io.Serializable {

    private String spaceNum;
    private Integer rateInCent;


    public RateTransmissionDetails() {
    }
    public RateTransmissionDetails(String spaceNum,Integer rateInCent) {

        this.spaceNum=spaceNum;
        this.rateInCent=rateInCent;
    } 


    @Column(name = "SpaceNum", nullable = false)
    public String getSpaceNum() {
        return this.spaceNum;
    }

    public void setSpaceNum(String spaceNum) {
        this.spaceNum = spaceNum;
    }

    @Column(name = "RateInCent", nullable = false)
    public Integer getRateInCent() {
        return this.rateInCent;
    }

    public void setRateInCent(Integer rateInCent) {
        this.rateInCent = rateInCent;
    }

and my service class is

我的服务类是

Set<RateTransmissionDetails> rateTrmDtls = new HashSet<RateTransmissionDetails>();
rateTrmDtls.add((new RateTransmissionDetails("A",new Integer(20)));

I am getting the error

我收到了错误

2012-11-02 16:44:02,796[http-6060-3] WARN duncansolutions.databus.external.controller.rate.RateController - Error message to caller: com.duncansolutions.databus.external.bean.hibernate.rate.RateTransmissionDetails cannot be cast to java.lang.String

2012-11-02 16:44:02,796 [http-6060-3] WARN duncansolutions.databus.external.controller.rate.RateController - 调用者的错误消息:com.duncansolutions.databus.external.bean.hibernate.rate.RateTransmissionDetails无法强制转换为java.lang.String

Can any body tell me how to go about it.

任何人都可以告诉我如何去做。

1 个解决方案

#1


0  

Set<RateTransmissionDetails> rateTrmDtls = new HashSet<RateTransmissionDetails>(); 
rateTrmDtls.add(new RateTransmissionDetails("A",new Integer(20)));

There is nothing wrong here. The error probably occurs when you use that set rateTrmDtls to do something, and the code expects a set of String

这里没有错。当您使用set rateTrmDtls执行某些操作时,可能会发生该错误,并且代码需要一组String

Can you show the code where you use the set in RateController?

你可以在RateController中显示使用set的代码吗?

#1


0  

Set<RateTransmissionDetails> rateTrmDtls = new HashSet<RateTransmissionDetails>(); 
rateTrmDtls.add(new RateTransmissionDetails("A",new Integer(20)));

There is nothing wrong here. The error probably occurs when you use that set rateTrmDtls to do something, and the code expects a set of String

这里没有错。当您使用set rateTrmDtls执行某些操作时,可能会发生该错误,并且代码需要一组String

Can you show the code where you use the set in RateController?

你可以在RateController中显示使用set的代码吗?