Skip to content

lojones/DatasourceToPojoMapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JDBC resultset to Java POJO mapper

Conveniently convert a row from a JDBC resultset to a java object given that the database follows uppercase-underscore naming convention with names matching java object field names.

IE

database table and column names

USER_DETAIL.USER_ID
USER_DETAIL.NUMERICAL_ID
USER_DETAIL.FIRST_NAME
USER_DETAIL.LAST_NAME
USER_DETAIL.PASSWORD
USER_DETAIL.BIRTH_DATE

java pojo object field names matching column names above

public class User {
  String userId;  
  Integer numericalId;  
  String firstName;  
  String lastName;  
  String password;  
  Date birthDate;  
  ... + getters and setters for these fields
}

Usage

DataSourceToPojoMapper dataSourceToPojoMapper = new DataSourceToPojoMapper();

ResultSet rs = preparedStatement.execute();

List<User> users=new ArrayList<User>();

while (rs.next())
{
	User user = dataSourceToPojoMapper.getMappedObj(rs, User.class);	
	users.add(user);
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages