Bonjour,

j'ai un petit souci sur l'insertion d'une entity via Hibernate dans ma base.

j'ai ce joli message de ma base
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
	at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)
	at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)
	at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1316)
	at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:881)
	at com.cwfse.DAO.Implementation.JPAStatiqValuesDao.persistEntity(JPAStatiqValuesDao.java:62)
	at com.cwfse.traitements.ObjectsToXml.CCAMAction(ObjectsToXml.java:990)
	at com.cwfse.websocket.WsocketHandler$WSocket.onMessage(WsocketHandler.java:162)
	at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455$WSFrameHandler.onFrame(WebSocketConnectionRFC6455.java:845)
	at org.eclipse.jetty.websocket.WebSocketParserRFC6455.parseNext(WebSocketParserRFC6455.java:359)
	at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455.handle(WebSocketConnectionRFC6455.java:235)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
	at java.lang.Thread.run(Unknown Source)
dans mon persistence.xml, je subodore que cette propriété, me perturbe mon enregistrement

<property name="hibernate.hbm2ddl.auto" value="update"/>

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?xml version="1.0" encoding="UTF-8"?>
<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" xmlns="http://java.sun.com/xml/ns/persistence">
  <persistence-unit name="CWFSE" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>com.cwfse.DAO.entities.MessagesErreur</class>
    <class>com.cwfse.DAO.entities.DocXslEntity</class>
    <class>com.cwfse.DAO.entities.RadiosPropEntity</class>
    <class>com.cwfse.DAO.entities.PratConfigEntity</class>
    <class>com.cwfse.DAO.entities.ReferEntity</class>
    <class>com.cwfse.DAO.entities.EtatFseEntity</class>
    <class>com.cwfse.DAO.entities.StatiqValues</class>
    <properties>
         <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
      <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
      <property name="javax.persistence.jdbc.url" value="jdbc:h2:file:bdd/cwfse_p;"/>
      <property name="javax.persistence.jdbc.user" value="sa"/>
      <property name="javax.persistence.jdbc.password" value=""/>
       <property name="cache.provider_class" value="org.hibernate.cache.internal.NoCacheProvider"/>
      <property name="hibernate.hbm2ddl.auto" value="update"/>
      <property name="hibernate.connection.useUnicode" value="true"/>
		<property name="hibernate.connection.characterEncoding" value="Cp1252" />
		<property name="hibernate.connection.charSet" value="Cp1252"/>
    </properties>
  </persistence-unit>
  <persistence-unit name="Session_App" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>com.cwfse.DAO.entities.BeneficiaireEntity</class>
    <class>com.cwfse.DAO.entities.PatientEntity</class>
    <class>com.cwfse.DAO.entities.PraticienEntity</class>
    <class>com.cwfse.DAO.entities.PSEntity</class>
    <properties>
      <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
      <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:cwfsedb"/>
      <property name="javax.persistence.jdbc.user" value="sa"/>
      <property name="javax.persistence.jdbc.password" value=""/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
      <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
       <property name="cache.provider_class" value="org.hibernate.cache.internal.NoCacheProvider"/>
    </properties>
  </persistence-unit>
</persistence>
L'entity en cause

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
@Entity
@NamedQueries({ 
    @NamedQuery(name = "StatiqValue.findAll", query = "SELECT e FROM StatiqValues e "),
    @NamedQuery(name = "StatiqValue.findByID", query = "SELECT e FROM StatiqValues e WHERE e.id = :id "),
    @NamedQuery(name = "StatiqValue.findByConstante", query = "SELECT e FROM StatiqValues e WHERE e.constante = :constante ")
})
@Table(name = "StatiqValue")
public class StatiqValues implements Serializable {
 
 
    private static final long serialVersionUID = 1L;
 
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ID_STVAL")
    private Long id;
    private String constante;
    private String valeur;
    private String commentaire;
si j'utilise un create, mes bases initialisées ne sont pas accessibles, et create-drop, comme son nom l'indique, ne sert que pendant la session.

Quelqu'un aurait une idée du mode a utiliser / configurer ?