Héllo,<br><br>I have some troubles getting hibernate 3.5 working properly with HSQLDB (in process mode), I got same issues with SQLite [1] but everything works as excepted with mysql.<br>I&#39;m new to hibernate and all this java art so forgive me if I make big errors.<br>
<br>The problem is each time I start my app which creates and populates serveral table, the next run the db seems empty, and I have to fill it again.<br><br>I&#39;ve setup a project using the 3.5 version of hibernate using JPA/EJB. I&#39;ve setup a persistence unit (thanks to netbeans) automatically generating the presistence.xml needed for the emf setup<br>
<br>persistence.xml<br><br>&lt;code&gt;<br><br>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;persistence version=&quot;1.0&quot; xmlns=&quot;<a href="http://java.sun.com/xml/ns/persistence">http://java.sun.com/xml/ns/persistence</a>&quot; xmlns:xsi=&quot;<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>&quot; xsi:schemaLocation=&quot;<a href="http://java.sun.com/xml/ns/persistence">http://java.sun.com/xml/ns/persistence</a> <a href="http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd</a>&quot;&gt;<br>
  &lt;persistence-unit name=&quot;PMMPU2&quot; transaction-type=&quot;RESOURCE_LOCAL&quot;&gt;<br>    &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;<br>    &lt;class&gt;model.Extrait&lt;/class&gt;<br>
    &lt;class&gt;model.Mot&lt;/class&gt;<br>    &lt;class&gt;model.Prefixe&lt;/class&gt;<br>    &lt;class&gt;model.Suffixe&lt;/class&gt;<br>    &lt;class&gt;model.Texte&lt;/class&gt;<br>    &lt;properties&gt;<br>      &lt;property name=&quot;hibernate.connection.username&quot; value=&quot;SA&quot;/&gt;<br>
      &lt;property name=&quot;hibernate.connection.driver_class&quot; value=&quot;org.hsqldb.jdbcDriver&quot;/&gt;<br>      &lt;property name=&quot;hibernate.connection.password&quot; value=&quot;&quot;/&gt;<br>      &lt;property name=&quot;hibernate.connection.url&quot; value=&quot;jdbc:hsqldb:file:db/base;shutdown=true&quot;/&gt;<br>
      &lt;property name=&quot;hibernate.cache.provider_class&quot; value=&quot;org.hibernate.cache.NoCacheProvider&quot;/&gt;<br>      &lt;property name=&quot;hibernate.hbm2ddl.auto&quot; value=&quot;update&quot;/&gt;<br>
    &lt;/properties&gt;<br>  &lt;/persistence-unit&gt;<br>&lt;/persistence&gt;<br><br>&lt;/code&gt; <a href="http://java.pastebin.com/LFfB0gSt">http://java.pastebin.com/LFfB0gSt</a><br><br>I have also a HibernateUtil which helps me with emf &amp; em:<br>
<br>&lt;code&gt;<br><br>public class HibernateUtil {<br><br>    private static EntityManagerFactory emf = null;<br>    private static EntityManager em = null;<br><br>    public static EntityManagerFactory getEmf()<br>    {<br>
        if(emf == null)<br>        {<br>                        Map&lt;String, Object&gt; configOverrides = new HashMap&lt;String, Object&gt;();<br>          //  configOverrides.put(&quot;hibernate.hbm2ddl.auto&quot;, &quot;update&quot;);<br>
            configOverrides.put(&quot;hibernate.show_sql&quot;, &quot;true&quot;);<br>            emf = Persistence.createEntityManagerFactory(&quot;PMMPU2&quot;, configOverrides);<br><br>        }<br>            return emf;<br>
    }<br><br>    public static EntityManager getEm()<br>    {<br>        if(em == null)<br>            em = getEmf().createEntityManager();<br>        return em;<br>    }<br> <br>}<br><br>&lt;/code&gt; <a href="http://java.pastebin.com/kvyxruH0">http://java.pastebin.com/kvyxruH0</a><br>
<br>1) As you can see I overdrive some settings getEMF.<br>2) How should a use EM instances; one for all the app, is that different on desktop &amp; web ?<br>3) How could I change HSQLDB options with hibernate to use CACHED tables by default ?<br>
<br>[1] sqliteJDBC <a href="http://www.zentus.com/sqlitejdbc/">http://www.zentus.com/sqlitejdbc/</a> + hibernate-sqlite <a href="http://code.google.com/p/hibernate-sqlite/">http://code.google.com/p/hibernate-sqlite/</a><br>