Bonjour,
J'ai un fichier persistance.xml contenant deux unités
Code xml : 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
44
45
46
47
48
49
50
51
52
53
54
<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at
 
 http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.   
-->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    version="1.0">
 
    <persistence-unit name="unit1" transaction-type="RESOURCE_LOCAL">
        <!--jta-data-source></jta-data-source-->
        <non-jta-data-source>osgi:services/javax.sql.DataSource/(name=source1)</non-jta-data-source>
        <class>foo.echange.model.I48500EventStore</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
 
        <properties>
            <!-- These properties are creating the database on the fly. We are using them to avoid users having
            to create a database to run the sample. This is not something that should be used in production.
            See also the create=true line in the ariestrader-derby-ds blueprint meta data -->
            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
            <property name="openjpa.jdbc.DBDictionary" value="oracle"/>
        </properties>
    </persistence-unit>
 
 
    <persistence-unit name="unit2" transaction-type="RESOURCE_LOCAL">
        <!--jta-data-source></jta-data-source-->
        <non-jta-data-source>osgi:services/javax.sql.DataSource/(name=source2)</non-jta-data-source>
        <class>foo.echange.model.I48502EventStore</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
 
        <properties>
            <!-- These properties are creating the database on the fly. We are using them to avoid users having
            to create a database to run the sample. This is not something that should be used in production.
            See also the create=true line in the ariestrader-derby-ds blueprint meta data -->
            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
            <property name="openjpa.jdbc.DBDictionary" value="oracle"/>
        </properties>
    </persistence-unit>
</persistence>
j'ai une classe mère que je ne veux pas persister et deux classes filles que je veux persister chacune dans une unité
Code java : 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
import javax.persistence.Column;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
// Je n'ai pas mis @Entity car je ne veux pas la persister 
// mais j'ai mis les annotations pour que les classes héritières mappent sur les bons champs 
@XmlType 
@XmlRootElement
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) public class EventStore
{   
    @Column(name = "EVENT_ID", unique = true, nullable = false)
    private int id;   
    @Column(name = "XID", columnDefinition = "VARCHAR2(200 BYTE)")
    private String xid;   
    @Column(name = "OBJECT_KEY", columnDefinition = "VARCHAR2(80 BYTE)")
    private String key;
    @Column(name = "OBJECT_NAME", columnDefinition = "VARCHAR2(40 BYTE)")
    private String name;
    @Column(name = "OBJECT_FUNCTION", columnDefinition = "VARCHAR2(40 BYTE)")
    private String function;
    @Column(name = "EVENT_PRIORITY", columnDefinition = "NUMBER(5,0)")
    private String priority;
    @Column(name = "EVENT_TIME", columnDefinition = "DATE")
    private String time;
    @Column(name = "EVENT_STATUS", columnDefinition = "NUMBER(5,0)")
    private String status;
    @Column(name = "EVENT_COMMENT", columnDefinition = "VARCHAR2(100 BYTE)")
    private String comment;   
    /**   
     *   
     */   
    public EventStore(){
        super();   
    }
    ...
}
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
@Entity @Table(name = "I48500_EVENTSTORE") 
public class I48500EventStore extends EventStore
{}
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
@Entity @Table(name = "I48502_EVENTSTORE") 
public class I48502EventStore extends EventStore
{}
Je m'attendais à ce que les tags
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
<exclude-unlisted-classes>true</exclude-unlisted-classes>
de mon persistance.xml sélectionne uniquement la classe définie dans l'unité de persistance.
Mais en fait j'obtiens des Warnings qui m’informe qu'aucune classe ne peut être persisté.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
109  unit1  WARN   [main] openjpa.Enhance - Type "class fr.aphp.ati.eai.hermes.ng485.echange.model.EventStore" loaded by java.net.URLClassLoader@9319d9 has no metadata; enhancing as persistence aware. If you intended for "class fr.aphp.ati.eai.hermes.ng485.echange.model.EventStore" to be persistence-capable, then this means that OpenJPA could not find any metadata for "class fr.aphp.ati.eai.hermes.ng485.echange.model.EventStore". This can happen if the directory containing your metadata is not in your CLASSPATH, or if your metadata files are not named properly. See the documentation on metadata placement for more information.
141  unit1  WARN   [main] openjpa.Runtime - Found no persistent property in "fr.aphp.ati.eai.hermes.ng485.echange.model.I48500EventStore"
187  unit1  WARN   [main] openjpa.Runtime - Found no persistent property in "fr.aphp.ati.eai.hermes.ng485.echange.model.I48502EventStore"
 15  unit2  WARN   [main] openjpa.Enhance - Type "class fr.aphp.ati.eai.hermes.ng485.echange.model.EventStore" loaded by java.net.URLClassLoader@9319d9 has no metadata; enhancing as persistence aware. If you intended for "class fr.aphp.ati.eai.hermes.ng485.echange.model.EventStore" to be persistence-capable, then this means that OpenJPA could not find any metadata for "class fr.aphp.ati.eai.hermes.ng485.echange.model.EventStore". This can happen if the directory containing your metadata is not in your CLASSPATH, or if your metadata files are not named properly. See the documentation on metadata placement for more information.
 31  unit2  WARN   [main] openjpa.Runtime - Found no persistent property in "fr.aphp.ati.eai.hermes.ng485.echange.model.I48500EventStore" 
 31  unit2  WARN   [main] openjpa.Runtime - Found no persistent property in "fr.aphp.ati.eai.hermes.ng485.echange.model.I48502EventStore"
j'ai lu et relu la doc, mais quelque chose m'échappe.
J’ai donc essayé à tatons.
Ajouter un @Entity à la classe mère ne change quasiment rien
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
141  unit1  WARN   [main] openjpa.Runtime - Found no persistent property in "fr.aphp.ati.eai.hermes.ng485.echange.model.I48500EventStore"
187  unit1  WARN   [main] openjpa.Runtime - Found no persistent property in "fr.aphp.ati.eai.hermes.ng485.echange.model.I48502EventStore"
 31  unit2  WARN   [main] openjpa.Runtime - Found no persistent property in "fr.aphp.ati.eai.hermes.ng485.echange.model.I48500EventStore"
 31  unit2  WARN   [main] openjpa.Runtime - Found no persistent property in "fr.aphp.ati.eai.hermes.ng485.echange.model.I48502EventStore"
Si une âme charitable pouvait m'éclairer de ses lumières, je lui en saurais gré.

le but est donc de définir un @Entité qui peut être persisté dans deux tables différentes
merci
A+JYT