有没有一个轻量级的ORM前端mvc框架有哪些看源码来学习如何设计ORM的

spring-data spring 的nosql的orm框架设计学习 - 我的技术旅程 - ITeye博客
博客分类:
1.spring-data-redis如何连接到redis服务端
其中定义了两个接口 org.springframework.data.redis.connection下的RedisConnection和RedisConnectionFactory工厂接口:
public interface RedisConnection extends RedisCommands {
void close() throws DataAccessE
boolean isClosed();
Object getNativeConnection();
boolean isQueueing();
boolean isPipelined();
void openPipeline();
List&Object& closePipeline();
其中RedisCommands接口定义了redis支持的所有操作接口,
public interface RedisConnectionFactory extends PersistenceExceptionTranslator {
RedisConnection getConnection();
RedisConnectionFactory接口只定义一个获取连接的方法,而PersistenceExceptionTranslator定义了出现异常时把异常转化为spring通用的DataAccessException异常,可以供spring统一处理。
spring-data-redis通过三种方式连接:
Jedis connector
&bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:host-name="server" p:port="6379"/&
JRedis connector
&bean id="jredisConnectionFactory" class="org.springframework.data.redis.connection.jredis.JredisConnectionFactory"
p:host-name="server" p:port="6379"/&
RJC connector
&bean id="jredisConnectionFactory" class="org.springframework.data.redis.connection.rjc.RjcConnectionFactory" p:host-name="server" p:port="6379"/&
而spring-data-redis是统一通过RedisTemplate类给用户操作
&bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:use-pool="true"/&
&!-- redis template definition --&
&bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"
p:connection-factory-ref="jedisConnectionFactory"/&
示例如下:
public class Example {
// inject the actual template
@Autowired
private RedisTemplate&String, String&
// inject the template as ListOperations
@Autowired
private ListOperations&String, String& listO
public void addLink(String userId, URL url) {
listOps.leftPush(userId, url.toExternalForm());
通过序列化接口org.springframework.data.redis.serializer来定制自己的序列化逻辑
public interface RedisSerializer&T& {
* Serialize the given object to binary data.
* @param t object to serialize
* @return the equivalent binary data
byte[] serialize(T t) throws SerializationE
* Deserialize an object from the given binary data.
* @param bytes object binary representation
* @return the equivalent object instance
T deserialize(byte[] bytes) throws SerializationE
存到redis上都是二进制的值,现在spring-data-redis里面已经提供了几种序列化机制:
JacksonJsonRedisSerializer json格式序列化
JdkSerializationRedisSerializer jdk的序列化
OxmSerializer spring的orm的序列化
StringRedisSerializer 简单的字符串跟字节转换序列化
3.spring-data-redis的消息发布订阅处理
&!-- this is the Message Driven POJO (MDP) --&
&bean id="messageListener" class="org.springframework.data.redis.listener.adapter.MessageListenerAdapter"&
&constructor-arg&
&bean class="redisexample.DefaultMessageDelegate"/&
&/constructor-arg&
&!-- and this is the message listener container... --&
&bean id="redisContainer" class="org.springframework.data.redis.listener.RedisMessageListenerContainer"&
&property name="connectionFactory" ref="connectionFactory"/&
&property name="messageListeners"&
&!-- map of listeners and their associated topics (channels or/and patterns) --&
&entry key-ref="messageListener"&
&bean class="org.springframework.data.redis.listener.ChannelTopic"&
&constructor-arg value="chatroom"&
&/property&
每次接收到消息,就会调用注册的listener来处理。
4.支持spring cache的处理抽象
&bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager" c:template-ref="redisTemplate"&
这样支持在本地缓存访问过的记录。
5.访问redis时支持回调,给程序员开发充分的扩展性灵活性来处理自定义的一些操作
通过扩展回调接口:
public interface RedisCallback&T& {
* Gets called by {@link RedisTemplate} with an active Redis connection. Does not need to care about activating or
* closing the connection or handling exceptions.
* @param connection active Redis connection
* @return a result object or {@code null} if none
* @throws DataAccessException
T doInRedis(RedisConnection connection) throws DataAccessE
这个接口可以直接操作connection对象,可以给开发充分的控制权进行操作。
然后通过调用redisTemplate的
public &T& T execute(RedisCallback&T& action) {
return execute(action, isExposeConnection());
* Executes the given action object within a connection, which can be exposed or not.
* @param &T& return type
* @param action callback object that specifies the Redis action
* @param exposeConnection whether to enforce exposure of the native Redis Connection to callback code
* @return object returned by the action
public &T& T execute(RedisCallback&T& action, boolean exposeConnection) {
return execute(action, exposeConnection, false);
实际上redisTemplate的所有操作都是通过这个回调接口来处理的
public List&Object& exec() {
return execute(new RedisCallback&List&Object&&() {
public List&Object& doInRedis(RedisConnection connection) throws DataAccessException {
return connection.exec();
public void delete(K key) {
final byte[] rawKey = rawKey(key);
execute(new RedisCallback&Object&() {
public Object doInRedis(RedisConnection connection) {
connection.del(rawKey);
public void delete(Collection&K& keys) {
final byte[][] rawKeys = rawKeys(keys);
execute(new RedisCallback&Object&() {
public Object doInRedis(RedisConnection connection) {
connection.del(rawKeys);
回调接口代码看起来很优雅,也非常灵活,设计得很不错。
浏览: 505806 次
来自: 杭州
语音实现在线听书http://blog.csdn.net/ls ...
http://viralpatel-net-tutorials ...
学习了素人派
谢啦........
不能 删除 写的不对的评论,楼主我错了。。。你能删除了吗?Access denied |
used Cloudflare to restrict access
Please enable cookies.
What happened?
The owner of this website () has banned your access based on your browser's signature (39b8b1c-ua98).&&&&&&&&轻量级ORM框架
正在努力加载播放器,请稍等…
正在努力加载播放器
大小:47.58KB&&所需金币:50
&& & 金币不足怎么办?
下载量:-次 浏览量:297次
贡献时间: 23:00:00
文档标签:
已有-位用户参与评分
同类热门文档
你可能喜欢
看过这篇文档的还看过
阅读:121&&下载:54
阅读:719&&下载:41
阅读:3066&&下载:26
阅读:238&&下载:12
阅读:296&&下载:4
阅读:115&&下载:0
阅读:121&&下载:0
阅读:77&&下载:0
阅读:143&&下载:0
阅读:303&&下载:0
该用户的其他文档
所需财富值:
50文件大小:47.58KB
您当前剩余财富值:&&
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
举报该文档侵犯版权。
例: /help.shtml当前位置: >
> JFinal (WEB+ORM框架) v3.2
JFinal (WEB+ORM框架) v3.2
源码大小:279KB
源码语言:简体中文
源码类型:
源码授权:开源软件
更新时间:
源码类别:java源码
源码官网:
应用平台:
网友评分:
内容介绍热点排行下载地址相关内容
PublicCMS是采用2016年最新主流技术开发的免费开源JAVACMS系统。商用免费,架构科学。无需任何数据库优化,即可支持上千万数据;支持全站静态化,动态页面缓存,SSI,0xml针对ExamStack V2.0进行了大量代码重构,同时也对数据模型做了部分调整最近找到的JAVA近百种算法大全 分享一下Elasticsearch Head插件是一款基于Elasticsearch的插件,ElasticSearch是一个基于Lucene的搜索服务器,使用Elasticsearch的关键就是安装head插件Jeewx是一个开源、高效、敏捷的微信开发平台,采用JAVA语言基于Jeecg快速开发框架实现,Jeewx开源版实现了微信平台的基础功能,便于用户二次开发QQ 聊天机器人小薇(XiaoV)是一个用java实现qq聊天机器人功能的web服务,可以用于社群互动JFinal 是基于 Java 语言的极速 WEB + ORM 框架,其核心设计目标是开发迅速、代码量少、学习简单、功能强大、轻量级、易扩展、Restful麦塔在线考试系统可以对各个院校各个专业下的学生进行专业知识的模拟考试,练习测试,课后练习,学校利用学校机房的电脑设备可以经常性的组织学习进行专业知识的考试考核因酷时代(inxedu)在线教育系统是一套研发并推出的国内首家Java版开源网校源代码建站系统,是用户体验最好、运营功能最全、性价比最高的在线教育软件,不仅解决了开发技术难belog博客程序是一个以tomcat进行开发的Java开源博客系统
JFinal (WEB+ORM框架) v3.2
CopyRight &
JB51.Net , All Rights ReservedOrmLite针对“持久化Java对象到数据库”提供了一些轻巧的功能。同时避免了更标准的ORM包的复杂性和开销。
通过添加注解设置自己的类。
强大的抽象数据库访问对象(DAO)类。
通过灵活的QueryBuilder轻松构建各种查询。
支持MySQL、Postgres、Microsoft SQL Server、H2、Derby、HSQLDB、Sqllite且可以相对容易的扩展到其他数据库。
临时支持(Provisional support)DB2、Oracle、ODBC和Netezza。如果不支持你的数据库,联系作者。
处理“编译”重复查询任务的SQL语句。
通过对象类型的属性支持,数据库中只存储外对象的id。
基本支持数据库事务。
自动生成创建、删除数据库表的SQL。
支持Spring配置。
支持不用注解配置表和字段。
支持Android SQLite数据库API的本地调用。
打赏支持我整理更多优质资源,谢谢!
打赏支持我整理更多优质资源,谢谢!
任选一种支付方式
资源整理者简介:
可能感兴趣的文章
按分类快速查找
关于资源导航
伯乐在线资源导航收录优秀的工具资源。内容覆盖开发、设计、产品和管理等IT互联网行业相关的领域。目前已经收录 1439 项工具资源。
关于资源导航
伯乐在线资源导航收录优秀的工具资源。内容覆盖开发、设计、产品和管理等IT互联网行业相关的领域。
新浪微博:
推荐微信号
(加好友请注明来意)
- 好的话题、有启发的回复、值得信赖的圈子
- 分享和发现有价值的内容与观点
- 为IT单身男女服务的征婚传播平台
- 优秀的工具资源导航
- 翻译传播优秀的外文文章
- 国内外的精选博客文章
- UI,网页,交互和用户体验
- 专注iOS技术分享
- 专注Android技术分享
- JavaScript, HTML5, CSS
- 专注Java技术分享
- 专注Python技术分享
& 2017 伯乐在线

我要回帖

更多关于 ssh框架搭建详细步骤 的文章

 

随机推荐