Hi all,
I am currently working on an object mapping library for Spring's "RowMapper" and released at github (https://github.com/serkan-ozal/spring-jdbc-roma) I know there is already a rowmapper named "org.springframework.jdbc.core.BeanPropertyRowMapp er" for binding resultset attributes to object. But it is reflection based and can cause performance problems. However my row mapper is not reflection based and it is byte code generation (with cglib and javassist) based row mapper. It generates rowmapper on the fly like implementing as manual so it has no performance overhead. It also supports object relations as lazy and eager. There are other lots of interesting features and these features can be customized with developer's extended classes. I give an example below about main idea for my rowmapper. If you are interested in, I can give you a detailed description about my rowmapper. Any suggestions and comments are welcome. Maybe it is useful for you while writing DAO classes
It supports all primitive types, enums, strings (char, varchar or clob), blob fields and object relations.
Here are some samples:
For "User" entity, you can get rowmapper like this:
For "User" entity configuration:
For more informations,
Here is GitHub URL: https://github.com/serkan-ozal/spring-jdbc-roma
Here is GitHub Wiki URL: http://serkan-ozal.github.io/spring-jdbc-roma/
--
Serkan ÖZAL
I am currently working on an object mapping library for Spring's "RowMapper" and released at github (https://github.com/serkan-ozal/spring-jdbc-roma) I know there is already a rowmapper named "org.springframework.jdbc.core.BeanPropertyRowMapp er" for binding resultset attributes to object. But it is reflection based and can cause performance problems. However my row mapper is not reflection based and it is byte code generation (with cglib and javassist) based row mapper. It generates rowmapper on the fly like implementing as manual so it has no performance overhead. It also supports object relations as lazy and eager. There are other lots of interesting features and these features can be customized with developer's extended classes. I give an example below about main idea for my rowmapper. If you are interested in, I can give you a detailed description about my rowmapper. Any suggestions and comments are welcome. Maybe it is useful for you while writing DAO classes
It supports all primitive types, enums, strings (char, varchar or clob), blob fields and object relations.
Here are some samples:
For "User" entity, you can get rowmapper like this:
Code:
@Autowired
RowMapperService rowMapperService;
...
RowMapper<User> userRowMapper = rowMapperService.getRowMapper(User.class);
For "User" entity configuration:
Code:
public class User {
@RowMapperField(columnName="id")
private Long id;
@RowMapperField(columnName="username")
private String username;
@RowMapperField(columnName="password")
private String password;
@RowMapperField(columnName="firstname")
private String firstname;
@RowMapperField(columnName="lastname")
private String lastname;
@RowMapperField(columnName="enabled")
private boolean enabled = true;
@RowMapperField(columnName="gender")
private Gender gender; // Note that Gender is enum, enums are supported by generated row mapper
@RowMapperObjectField(
provideViaSpringProvider =
@RowMapperSpringProvider(
provideCode = "@{roleDAO}.getUserRoleList(${id})"),
lazy = true)
private List<Role> roles = new ArrayList<Role>();
}
Here is GitHub URL: https://github.com/serkan-ozal/spring-jdbc-roma
Here is GitHub Wiki URL: http://serkan-ozal.github.io/spring-jdbc-roma/
--
Serkan ÖZAL