public class MapBeanTransformer<T> extends Object implements QueryMapper
| Constructor and Description |
|---|
MapBeanTransformer(Class<T> clazz,
Driver driver) |
| Modifier and Type | Method and Description |
|---|---|
void |
apply(Object instance,
String name,
Object value) |
Object |
createFrom(Object parentInstance,
String name)
Method called to get domain instance (POJO) when calling the
property() method. |
boolean |
map(ResultSetWrapper rsw,
Object instance,
List<MapColumn> mapColumns)
collecting the data from the database and put in the domain instance.
|
public Object createFrom(Object parentInstance, String name)
QueryMapperproperty() method.
This method is only called when there is a need to create a new instance.
If the parent instance is null, it means we are asking for the root object to be instantiated.
Otherwise we are asking an instance of the type defined by the property defined in 'name' in the parent instance.
Override this method to provide your own implementation for a different domain object.
We defer the setting of the instance, by returning a lambda, because we may wish not to set the value.
e.g: in an outer join, all related fields came as null, therefore it is a empty entitycreateFrom in interface QueryMapperparentInstance - parent instancename - name of the parent property that we want to instantiate forpublic void apply(Object instance, String name, Object value)
apply in interface QueryMapperpublic boolean map(ResultSetWrapper rsw, Object instance, List<MapColumn> mapColumns)
QueryMappermap in interface QueryMapperrsw - resultset wrapperinstance - domain instance to returnmapColumns - column mapping infoCopyright © 2019. All rights reserved.