开发者

IBatis Saving and Retrieving Different Type of Data in One DB Column

I have a requirement that I need to save different type of data (int, float, string) in one database table column. Presently, I have set the data type of column to BLOB.

Table in DB:

.........

OBJECT_VALUE BLOB

class ModelObjectValue() {

    public Object objectValue;

    //Getters and Setters of objectValue

    ...
}

Database column OBJECT_VALUE (Data Type Blob) is mapped to objectValue (Data Type java.lang.Object) property in ModelObjectValue.java.

Data in OBJECT_VALUE is either int, float or string. I successfully get the data in objectValue as java.lang.Object. But I can't convert/cast it back to int, float or string.

I have already tried开发者_如何学Go casting object to Integer, Float or String class. But all did not worked.

Please guide me about this issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜