I am using Play 1.2.5. I am using hibernate in my play project. I have added the database info in application.conf as follows
db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/dbname
db.user=username
db.pass=password
Also I have added the database info in the hibernate.cfg.xml under the conf folder as follows,
<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>
My application is running properly but I am not sure whether it is a good practise to define the db connections in both the files. Is there a way to define the db connection in a single place. Please correct me if I am wrong.
You don't need a Hibernate mapping file. Mapping is specified using JPA annotations on your model classes.
Have a read of the guide to get started.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.