-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathREADME
50 lines (32 loc) · 1.1 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
TypeMapper
----------
Introduction
------------
The TypeMapper is a small Java OR-Mapper for the Postgres Databases.
Other then other OR-Mappers it supports postgres database types, which are in general serialiazed to (field1,field2),
and arrays. It is designed as an extention to the spring dao package and it implements the interface ParameterizedRowMapper,
which is part of the spring framework.
Usage
-----
public class Obj {
@DatabaseField(name="field")
public int i;
}
TypeMapperFactory.createTypeMapper(Obj.class);
ValueTransformer
----------------
Sometimes a value cannot be translated 1:1 to a Java Object, for example enums.
For this case the TypeMapper has ValueTransformers, wchich are executed before the value is set.
public class Obj {
@DatabaseField(name="field", transformer=MyEnumTransformer.class)
public MyEnum e;
}
public class GenderCodeTransformer extends ValueTransformer<String, MyEnum> {
@Override
public MyEnum transform(final String string) {
return MyEnum.fromCode(string);
}
}
Further informations
-------------------
Have a look into the tests