用Spring的Converter API生成VoltDB的資料物件
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.
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部落格 ” ,連結:http://blog.itpub.net/301743/viewspace-733664/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 一個命令,生成資料庫物件的指令碼資料庫物件指令碼
- 用Powerdesigner的PDM生成資料庫及逆向生成資料庫
- 用Java開發VoltDB程式Java
- MongoDB 在 Spring的資料應用MongoDBSpring
- Laravel API 文件生成器生成指定的 API 文件LaravelAPI
- 用nodepad++生成匯入資料的SQLSQL
- [PHP]為JSON資料的API返回空陣列或者空物件PHPJSONAPI陣列物件
- 686K TPS with Spring Framework Web App and VoltDBSpringFrameworkWebAPP
- VoltDB讓Kafka支援複雜資料流驅動的實時業務決策Kafka
- 用指向基類物件的指標輸出資料物件指標
- 用Python生成MySql資料字典PythonMySql
- API介面在電商商品資料獲取中的應用API
- API資料介面在電子商務中的應用API
- 商品API資料在電商中的應用與實現API
- 用java的api將資料從HDFS上存到HBASE中JavaAPI
- YodaOS 中是如何生成 API 的?API
- VoltDB - NewSQL DatabaseSQLDatabase
- Spring型別轉換(Converter)Spring型別
- javascript生成map物件的函式JavaScript物件函式
- 資料庫中的重要物件資料庫物件
- 資料物件的快取策略物件快取
- 物件業務的修改資料介面物件
- 一個給 Java 程式設計師用的 Api 文件生成工具Java程式設計師API
- 使用dbunit測試spring + mybatis的資料庫應用SpringMyBatis資料庫
- 實用!一鍵生成資料庫文件,堪稱資料庫界的Swagger資料庫Swagger
- 用資料島生成翻頁程式 (轉)
- 搶佔市場先機:利用API商品資料介面啟用您的資料資產API
- MYSQL中的DDL(用來操縱資料庫物件的語言)1MySql資料庫物件
- 如何將jquery生成的物件轉換成dom物件jQuery物件
- java快速的生成測試資料Java
- 資料科學的原理與技巧二、資料生成資料科學
- 線上生成二維碼的API介面API
- Apache Cassandra 的 Spring 資料ApacheSpring
- Spring API 的 CORS 測試SpringAPICORS
- 生成Oracle 資料庫的ER圖的工具Oracle資料庫
- 用PHP的生成器yield處理大量資料,確實很快!PHP
- 將VAE用於時間序列:生成時間序列的合成資料
- 基於 Node+express 爬蟲的資料 API,爬一套自己的api資料(二)Express爬蟲API