Play Framework 1 hibernate集成

时间:2014-04-04 11:07:08

标签: java hibernate playframework playframework-1.x hibernate3

我正在使用Play 1.2.5。我在我的游戏项目中使用了hibernate。我在application.conf中添加了数据库信息,如下所示

db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/dbname
db.user=username
db.pass=password

另外,我在conf文件夹下的hibernate.cfg.xml中添加了数据库信息,如下所示,

<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/dbname</property>
<property name="hibernate.connection.username">username</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

我的应用程序运行正常,但我不确定在两个文件中定义数据库连接是否是一个好习惯。有没有办法在一个地方定义数据库连接。如果我错了,请纠正我。

1 个答案:

答案 0 :(得分:1)

您不需要Hibernate映射文件。使用模型类上的JPA注释指定映射。

阅读the guide以开始使用。