Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Hiberanteconfig

fschoeppl edited this page Oct 23, 2012 · 5 revisions

By default the embedded server uses a HSQL in memory database. To use the database of your choice, you have to adjust following file:

  • src/main/resources/META-INF/persistence.xml

Hibernate config for PostgreSQL

First you need to setup a user and the database within your PostgreSQL installation. To do this, execute following steps:

# connect via ssh to your server with postgre
su - postgres
psql
create user dbu_core with password 'dbu_core';
create database bmucore  encoding 'UTF8';
grant connect on database bmucore to dbu_core;
# the scheme and user have been setup successfully
\q #to exit

Next update persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
	version="2.0">
	<persistence-unit name="org.backmeup.jpa"
		transaction-type="RESOURCE_LOCAL">
		<provider>org.hibernate.ejb.HibernatePersistence</provider>
		<class>org.backmeup.model.BackMeUpUser</class>
		<class>org.backmeup.model.ProfileEntry</class>
		<class>org.backmeup.model.Profile</class>
		<class>org.backmeup.model.Status</class>
		<class>org.backmeup.model.BackupJob</class>
		<class>org.backmeup.model.ProfileOptions</class>
		<class>org.backmeup.model.ActionProfile</class>
		<class>org.backmeup.model.ActionProfile$ActionProperty</class>
		<class>org.backmeup.model.FileItem</class>
		<class>org.backmeup.model.UserProperty</class>
		<class>org.backmeup.model.Service</class>
		<class>org.backmeup.model.JobProtocol</class>
		<class>org.backmeup.model.JobProtocol$JobProtocolMember</class>
		<class>org.backmeup.model.Token</class>
		<class>org.backmeup.model.SearchResponse</class>
		<properties>
			<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
			<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://192.168.80.130/bmucore" />
			<property name="javax.persistence.jdbc.user" value="dbu_core" />
			<property name="javax.persistence.jdbc.password" value="dbu_core" />
			<property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
			<property name="hibernate.connection.url" value="jdbc:postgresql://192.168.80.130/bmucore" />
			<property name="hibernate.connection.username" value="dbu_core" />
			<property name="hibernate.connection.password" value="dbu_core" />
			<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
		</properties>
	</persistence-unit>
</persistence>

Add the driver to the pom-File (org.backmeup.embedded):

<dependency>
  <groupId>postgresql</groupId>
  <artifactId>postgresql</artifactId>
  <version>9.1-901.jdbc4</version>
</dependency>

Finally you have to rebuild the org.backmeup.embedded project (as we have changed a configuration file). Run the embedded server just as usual and test it by running some python tests

Clone this wiki locally