Almost all is in the title... Persistence is working fine when app launched, and row are still in DB when the app is closed, but once app is loaded, rows got deleted...
I'm using an already existing database structure, through the mysql5 SGBD.
Seems to be coming from my entity manager declaration. Here are a few lines of my code, (entity manager statement, and persistence.xml)
entityManager statement:
entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory(resourceMap.getString("entityManager.persistenceUnit")).createEntityManager();
query = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery(resourceMap.getString("query.query"));
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" 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_1_0.xsd">
<persistence-unit name="AnalysesPU" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.PersistenceProvider
<class>solianceanalysesmanager.Produits
<properties>
<property name="toplink.jdbc.user" value="XXX"/>
<property name="toplink.jdbc.password" value="X"/>
<property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/Analyses"/>
<property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
</properties>
</persistence-unit>
</persistence>
Does someone have an idea of this strange problem cause? I already got suggested that my entityManager was reinitialising persistence context on its statement...
PS: Since i'm french, it's possible i mis-used or mis-spelled some words. Feel free to ask me to reformulate.
TopLink Essentials does not recreate your tables by default, but this can be configured in your persistence.xml.
See, http://wiki.eclipse.org/EclipseLink/Examples/JPA/DDL
My guess is you are using Glassfish? I believe Glassfish does this by default in development mode, and there is some Glassfish setting you need to configure to avoid this. I'm not sure how this is configured in Glassfish though, perhaps someone else does.