轻量级 Java 事务管理 [英] lightweight java transaction management

查看:27
本文介绍了轻量级 Java 事务管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为主要针对智能手机的回合制持久世界游戏开发游戏服务器,我目前正在开始实施持久层,我正在寻找一些技巧/建议.

I'm currently working on a game server for a turn-based persistent world game primarily targeted at smartphones, and I'm currently beginning to implement the persistence layer and I'm looking for some tips/advice.

我最初计划将 mybatis 用于持久层,mybatis-guice 插件实现了一个简单的 @Transactional 注释,它类似于 Spring 的但没有整个框架的重量.不幸的是,我放弃了 mybatis,因为我发现我与 ORM 的斗争太多了,而且我的关系设计并没有特别好地规范化.现在我基本上在使用 JDBC,而且我真的在努力避免编写大量样板代码来管理 DAO 调用字符串中的事务和连接.

I originally planned to use mybatis for the persistance layer and the mybatis-guice addon implemented a simple @Transactional annotation that is similar to Spring's but without the weight of that entire framework. Unfortunately I ditched mybatis since I found I was fighting with the ORM too much and my relational design doesn't normalize particularly well. Now I'm basically using JDBC and I'm really trying to avoid writing tons of boilerplate code for managing transactions and connections within a string of DAO calls.

我也避免在此处使用任何应用程序服务器或添加使用 spring,因为它们似乎不适合,服务器直接在 netty 之上运行 java.鉴于这些条件,是否有任何简单的事务管理器,或者我是否试图推出自己的交易管理器?像 mybatis-guice 的 @Transactional 这样的东西会很棒.

I'm also avoiding using any application server here or adding using spring since they don't seem to fit in, the server runs in straight up java on top of netty. Given these conditions are there any simple transaction managers or am I stuck trying to roll my own? Something like mybatis-guice's @Transactional would be great.

推荐答案

Spring 和 Hibernate 的组合是最好的 IMO,两者都非常轻巧,具体取决于您的需求.

Spring and Hibernate combination is best IMO both are quite light depending on your needs.

目前我们正在使用 OpenJPA,并且对此也很满意.

Currently we are using OpenJPA and quite happy with that too.

它需要多轻??使用 Spring 和 Hibernate,它们很轻.Guice 是一个简单且轻量级的 DI 框架,我相信您知道这一点,但是通过添加事务管理等内容,您最终会得到太多低端开源产品*(我并不是说 Guice 是低端的)* 你会发现它并不比其他开源替代品更轻,而且社区支持也更少,因为没有多少人会使用它们.

How light does it need to be ?? Go with Spring and Hibernate they are light. Guice is simple and light weight DI framework which I am sure you are aware of but by adding on stuff like transaction management etc you will end up with too many lower end opensource products*(I am not saying that Guice is lower end by any means)* which you will find are not any lighter than other opensource alternatives and will have less community support since not many people will be using them.

这篇关于轻量级 Java 事务管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆