![](/img/trans.png)
[英]Is there any way to get Play framework and JPA to use underscores in column names?
[英]Is there a way to use MyBatis with the Play! framework?
首先,在选择最佳的Java Web框架方面,请使用\\ m /。由于我们拥有优秀的Oracle PL / SQL开发人员,因此我们希望放弃默认的JPA插件,而改用MyBatis。 我检查了回购,目前没有模块。 有人可以为我们说明如何做吗? 此外,它将与CRUD模块一起使用吗?
我使用像这样的助手类:
public class DBSession {
public SqlSession openSession() throws IOException {
SqlSessionFactory sessionFactory = getFactory();
return sessionFactory.openSession();
}
private SqlSessionFactory getFactory() throws IOException {
String resource = "mybatis/conf/ibatis.xml";
Reader reader = Resources.getResourceAsReader(resource);
SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(reader);
return sessionFactory;
}
}
注意引用MyBatis配置的“ mybatis / conf / ibatis.xml”字符串。 为了获得更好的性能,我认为您可能希望缓存getFactory结果。
如果您使用的是Play 2.0,则可以直接使用mybatis-scala,不需要任何模块。 看这个完整的例子:
http://www.fdmtech.org/2012/03/a-better-example-of-play-framework-2-0-with-mybatis-for-scala-beta/
我不是MyBatis专家,但除非它使用标准的JPA注释,否则它可能无法与CRUD模块一起使用。
关于如何做到这一点,创建一个Play插件并使用EBeans作为如何实现它的灵感,因为它解决了类似的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.