Reputation: 13816
I have a model instance already, it's a basic POJO, how can I populate it (by issuing a SELECT
) with the values using dbutils by calling the setters which are named to match the table column names?
So BasicRowProcessor should match, I just don't find the appropiate class/method to call with the object as parameter.
There is only one instance I want to set, not an array.
Upvotes: 0
Views: 753
Reputation: 1444
I'm not sure I understand your question. Some source code would help.
There are lots of libraries that perform ORM. See source forge for some ORM projects. One of them is sormula which I created. For the simplest use of it, see POJO zero-config example.
Upvotes: 1
Reputation: 5553
All you can do is
YourObject result = new BasicRowProcessor().toBean(yourResultSet,YourObject.class);
It will create the instance though. This API is not designed to allow you to modify an already existing object.
If you really need to update the existing object you might implement a YourObject.copy(YourObject obj)
method and call it with the result from BasicRowProcessor.toBean
but it looks quite ugly.
An other (also ugly) solution would be to implement the BeanProcessor
class, implement the BeanProcessor.newInstance(Class)
method to return your object, then pass your implementation instance to the BasicRowProcessor
instance.
Upvotes: 0