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'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've setup a project using the 3.5 version of hibernate using JPA/EJB. I've setup a persistence unit (thanks to netbeans) automatically generating the presistence.xml needed for the emf setup<br>
<br>persistence.xml<br><br><code><br><br><?xml version="1.0" encoding="UTF-8"?><br><persistence version="1.0" xmlns="<a href="http://java.sun.com/xml/ns/persistence">http://java.sun.com/xml/ns/persistence</a>" xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>" xsi:schemaLocation="<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>"><br>
<persistence-unit name="PMMPU2" transaction-type="RESOURCE_LOCAL"><br> <provider>org.hibernate.ejb.HibernatePersistence</provider><br> <class>model.Extrait</class><br>
<class>model.Mot</class><br> <class>model.Prefixe</class><br> <class>model.Suffixe</class><br> <class>model.Texte</class><br> <properties><br> <property name="hibernate.connection.username" value="SA"/><br>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/><br> <property name="hibernate.connection.password" value=""/><br> <property name="hibernate.connection.url" value="jdbc:hsqldb:file:db/base;shutdown=true"/><br>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/><br> <property name="hibernate.hbm2ddl.auto" value="update"/><br>
</properties><br> </persistence-unit><br></persistence><br><br></code> <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 & em:<br>
<br><code><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<String, Object> configOverrides = new HashMap<String, Object>();<br> // configOverrides.put("hibernate.hbm2ddl.auto", "update");<br>
configOverrides.put("hibernate.show_sql", "true");<br> emf = Persistence.createEntityManagerFactory("PMMPU2", 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></code> <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 & 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>