开发者

mapping Field with variable type using Hibernate Annotaion

how can I have a field with variable type in my class? I use hibernate a开发者_开发技巧nnotation for mapping to DB. I tried to use java.io.Serializable as field's type, but it mapped to database as a 01 amount which is true if I get it's object and cast it to it's true type. but I need to run a query on this objects that needs true amount of field.(right now I can't compare an integer field with a number) Does anyone have any idea how can I do this?

Thanks in advance.


You can't have variable types in Java - it is statically typed language.

I guess you can achieve something like this with groovy (+ grails), which is dynamically typed. Using something like def someField you can later use someField as whatever you expect it to be.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜