![](/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.