My name is Vasyl Khrystiuk‎ > ‎process‎ > ‎main‎ > ‎

light DB

TBD

SQLite
HSQLDB(HyperSQL)
Derby(JAVA DB)
H2
Migration and change menegment with liquibase.

stuf:




*) installing
*) run commandline client
*) server mode?
*) file-based mode?
*) inmemory db
*) maven instalation for unit testing (inmemory db)
*) concurrent access
*) jdbc
*) hibernate support
*) other languages (php)
*) handy editor



HSQLDB


Maven instalation:
    <dependency>
        <groupId>org.hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <version>2.2.8</version>
    </dependency>

Usage in unit testing (inmemory db):
org.hibernate.cfg.Configuration cfg = getConfiguration();
cfg.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbc.JDBCDriver");
cfg.setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:testdb");
cfg.setProperty("dialect", "org.hibernate.dialect.HSQLDialect");
cfg.setProperty("hibernate.connection.username", "SA");
cfg.setProperty("hibernate.connection.password", "");

Usage file based db:
"jdbc:hsqldb:file:test"
"jdbc:hsqldb:file:c:\databases\test"
Also there is "res:" protocol support fro reading db from jar file(readonly db)



H2

pom.xml:

   <dependency>
  <groupId>com.h2database</groupId>
  <artifactId>h2</artifactId>
  <version>1.3.170</version>
  </dependency>

spring-context.xml:
<!-- Database -->
<jdbc:embedded-database id="datasource" type="H2"></jdbc:embedded-database>

JPA persistance file:
META-INF\persistence.xml

<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="name_org.hibernate.tutorial.jpa">
        <description>
            Persistence unit for the JPA tutorial of the Hibernate Getting Started Guide
        </description>

        <class>org.hibernate.tutorial.em.Event</class>

        <properties>
            <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE" />
            <property name="javax.persistence.jdbc.user" value="sa" />
            <property name="javax.persistence.jdbc.password" value="" />

            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.hbm2ddl.auto" value="create" />
        </properties>

    </persistence-unit>

</persistence>


SQLite

EXTRA NOTE: entity MUST contain at least one no-id property.



Liquibase


        Note: Looking at the liquibase-hibernate docs, you might not even know there was a liquibase:diff maven goal.  Here’s some better documentation on the plugin, goals, and configs: http://site.kuali.org/db/liquibase/2.0.2/liquibase-maven-plugin/plugin-info.html






ċ
test.7z
(11k)
Vasyl Khrystiuk,
24 May 2013, 16:13
Comments