首页 > Linux操作系统 > Linux操作系统 > 用Spring的Converter API生成VoltDB的数据对象

用Spring的Converter API生成VoltDB的数据对象

原创 Linux操作系统 作者:jieforest 时间:2012-06-24 07:50:11 0 删除 编辑
Mapping one type to another is a pretty common task. Hibernate and other ORM’s map a result from a data source’s native representation to an application specific representation.
In English, I want to convert a JDBC result set, or data objects, into a collection of POJOs (plain old Java objects) using some kind of data mapping tool or API.

Spring exposes a low level service provider interface that makes it very easy to convert one data type to another with either built-in converters or customer converters, allowing a developer to support just about any conversion one can think of.

Today I am writing about how to convert VoltDB's VoltTable result object into an application specific POJO using the Spring Converter API.Why even have a converter API in any application? A fairly common pattern in any database backed application is the value object (VO) to data access object (DAO) mapping.

A similar pattern is the transfer object to entity pattern. The data layer object is generally a mapping of fields to database table columns or query results.  That data layer object may contain additional objects that map to other tables too.

It may also expose methods, either explicitly or implicitly, to perform. the usual CRUD operations or it can rely on a service to accomplish those operations.The application layer object may include some or all of the data layer fields as well as application layer specific fields.

A data layer object may represent a student and the grades she got on all her tests while the application layer object may represent the student, the grades and then additional fields like the average, highest and lowest grades for each of those tests.

The importance of the converter API is that it makes it possible to abstract the link between the data access layer and the application layer objects such that either layer can be swapped out or updated without impacting the other layer.

Further, changes to the application layer object may not need to be persisted to the database while changes to the DAO are often persisted to the database.

来自 “ ITPUB博客 ” ,链接:,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录


  • 博文量
  • 访问量