Reputation: 1675
I'm using jdbcTemplate, and have a ResultSet consisting of about 100 named fields. And I have some object (bean), consisting of all those fields and appropriate getters/setters. Is there any way to just quickly map the result set to my object, so I don't need to manually call all those setters? Of course, assuming, that ResultSet returns fields with proper alias for every field?
Upvotes: 1
Views: 2012
Reputation: 1675
Answering to myself - BeanPropertyRowMapper is what I need, many thanks to google
Upvotes: 4
Reputation: 206796
Mapping from database tables / columns to Java objects is called object-relational mapping.
The standard Java API for this is the Java Persistence API (JPA). There are several implementations of this API; one of the most well-known is Hibernate.
Note that JPA works on a higher level than JDBC. It's not simply a tool for converting a JDBC ResultSet
to Java objects; it's a complete framework for mapping Java objects to and from records in a relational database.
There are also non-JPA based solutions such as mybatis (formerly iBATIS).
Upvotes: 1