Announcement Announcement Module
Collapse
No announcement yet.
Spring Roo + GWT - Persistence problem with HSQLDB Database Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Roo + GWT - Persistence problem with HSQLDB Database

    hi, I am using Spring Roo to develop a project in GWT. After trying a few samples can not still persist objects in the database. Each time I restart or reload data from the tables, values disappear. This is my log.roo file
    Code:
    // Spring Roo 1.1.2.RELEASE [rev fbc33bb] log opened at 2011-04-12 14:38:57
    project --topLevelPackage com.despesas
    persistence setup --provider HIBERNATE --database HYPERSONIC_PERSISTENT
    enum type --class ~.shared.domain.Genero
    enum constant --name HOMEM
    enum constant --name MULHER
    entity --class ~.server.domain.Funcionario --testAutomatically
    field string --fieldName Nome --notNull
    field string --fieldName userName --sizeMin 3 --sizeMax 30 --notNull
    field string --fieldName departmento
    field reference --type Funcionario supervisor
    field enum --fieldName sexo --type ~.shared.domain.Genero
    field boolean --fieldName admin --notNull
    entity --class ~.server.domain.Report --testAutomatically
    field string --fieldName proposta
    field string --fieldName notas
    field date --fieldName criado --type java.util.Date
    field string --fieldName departamento
    field reference --type Funcionario reporter
    field reference --type Funcionario AprovacaoSupervisor
    entity --class ~.server.domain.Despesa --testAutomatically
    field number --type java.lang.Double montante
    field string --fieldName descricao
    field reference --type Report report
    field string --fieldName aprovacao
    field string --fieldName categoria
    field date --fieldName criado --type java.util.Date
    field string --fieldName motivoRecusa
    gwt setup
    logging setup --level INFO
    quit
    dependency add --groupId com.google.appengine --artifactId appengine-api-1.0-sdk --version 1.4.0
    quit
    perform eclipse
    quit
    Would I be making a wrong configuration in persistence.xml file or HSQLDB Database is not recommended to deposit and maintain persistence.

    This is my persistence.xml file
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
                <!-- value="create" to build a new database on each run; value="update" to modify an existing database; value="create-drop" means the same as "create" but also drops tables when Hibernate closes; value="validate" makes no changes to the database -->
                <property name="hibernate.hbm2ddl.auto" value="update"/>
                <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
                <property name="hibernate.connection.charSet" value="UTF-8"/>
                <!-- Uncomment the following two properties for JBoss only -->
                <!-- property name="hibernate.validator.apply_to_ddl" value="false" /-->
                <!-- property name="hibernate.validator.autoregister_listeners" value="false" /-->
            </properties>
        </persistence-unit>
    </persistence>
    I´ve changed <property name="hibernate.hbm2ddl.auto" value="create"/> to <property name="hibernate.hbm2ddl.auto" value="update"/> after creation.

  • #2
    The HSQL db is an in-memory DB by default. This means when you shut down your app the data is lost. Changing your settings in persistence.xml is the correct approach - if you use a DB which actually persists data to disk . Try MySQL or Postgres.

    Comment


    • #3
      Originally posted by Stefan Schmidt View Post
      The HSQL db is an in-memory DB by default. This means when you shut down your app the data is lost. Changing your settings in persistence.xml is the correct approach - if you use a DB which actually persists data to disk . Try MySQL or Postgres.
      Thanks a lot Stefan for your answer. I´ll try MYSQL.

      Comment


      • #4
        I had the same problem but it fixed changing 'create' to 'update'. @xerife, make sure your server is running the updated version of persistence.xml.

        I don't agree with the name of HYPERSONIC_PERSISTENT if it's not going to be really persistent. Maybe roo could change to 'update' automatically.

        Comment


        • #5
          When using HYPERSONIC_PERSISTENT, I start the database before loading roo, with the following command (for example):
          Code:
          java -cp /home/stewarta/.m2/repository/org/hsqldb/hsqldb/1.8.0.10/hsqldb-1.8.0.10.jar org.hsqldb.Server --database.0 file:tmp/foo --dbname.0 xdb
          Alan

          Comment

          Working...
          X