tags:

views:

38

answers:

1

Hi.

how can I have a field with variable type in my class? I use hibernate annotation 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.

A: 

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.

Bozho