Micael Carvalho wrote:This code doesn't work of course, but is there anything that can be close to it?
My project is to build an automate database manager, not like Hibernate, I do not want the user to write queries, that's why it is needed to me to have а reference to the field of the class received.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Micael Carvalho wrote:Let's suppose Person is a superclass, and it has 2 subclasses: Doctor and Teacher. Let's also suppose that for some reason, each of these subclasses have a different named Field for keeping the Name of the person.
Micael Carvalho wrote:I must know what fields to use null values in "where" and what fields not to, there's where I'm stuck... Using reflection I can get all fields and so on, but how can I know which one should I put the "null" in "where" and which I shouldn't?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Micael Carvalho wrote:But when there is a null value in any of it's attributes, how to know if I should use "where attrname = null" or just ignore it?
There are cases I must use "attrname = null" (when I want a specific Person that has no name, for instance), and also cases I shouldn't use "attrname = null" (just ignore it), in case I want to select a Person by the date of birth (then, all fields will be null and date of birth will be filled out).
You see?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Micael Carvalho wrote:That is why I am trying to find a way to tell Java which fields should it allow to be used as null value. And it must not be an annotation, because it would be valid for the whole class, and this is just a select case, I could find a Person by it's ID, having the name null and not wanting to have "where name is NULL" on my query.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Micael Carvalho wrote:I just need to know "when" to consider the null value as a parameter to my query and "when" not to (sounds like a logic issue, but what I need to know is: Does Java provide any way to pass this extra information to the method?).
Consider Paul's rocket mass heater. |