简体   繁体   English

如何使用DbUnit 2.4.8自定义实体的列的映射

[英]How to customize the Mapping of a column of an Entity with DbUnit 2.4.8

In my project, to make tests, DbUnit 2.4.8 and org.unitils 3.3 are used with openjpa 1.2.2 在我的项目中,要进行测试,请在openjpa 1.2.2中使用DbUnit 2.4.8和org.unitils 3.3

When i want to execute test, i have a problem for the creation of one table. 当我想执行测试时,创建一个表存在问题。 This is the error i receive : 这是我收到的错误:

org.unitils.core.UnitilsException: Error inserting test data from DbUnit dataset for method public void be.fed.minfin.adminctx.backend.dao.impl.HistMouvementDAOTest.testMoveStepAndPhaseForward()
  at org.unitils.dbunit.DbUnitModule.insertDataSet(DbUnitModule.java:156)
  at 
  ......................
  Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is <openjpa-1.2.2-r422266:898935 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: *unexpected token: ORDER {stmnt 17691874 CREATE TABLE CatDocumentTypeModeleLabelLevel (Langue VARCHAR(255) NOT NULL, SIDCatDocumentTypeModeleLevel INTEGER NOT NULL, Label VARCHAR(255), Level INTEGER, Order INTEGER, Phase INTEGER, Visible BIT, PRIMARY KEY (Langue, SIDCatDocumentTypeModeleLevel))} [code=-5581, state=42581]*
  at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:375)
  at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:377)

Actually, there is a table created with a column named "order" (represented by the Entity "Niveau") . 实际上,有一个表创建了一个名为“ order”(由实体“ Niveau”表示)的列。 And I have to use this (it is not me that has created this table). 我必须使用它(不是我创建了此表)。

In the persistence-test.xml, i use the property ; 在persistence-test.xml中,我使用属性; openjpa.jdbc.SynchronizeMappings with the value buildSchema(ForeignKeys=true) to make automatically the mapping with the Entities. 使用值为buildSchema(ForeignKeys = true)的openjpa.jdbc.SynchronizeMappings来自动进行与实体的映射。

And i declare also, all the classes (entities) that are used in the tests. 我还声明了测试中使用的所有类(实体)。

For only one Entity, i would like to configure the name of the column "order", to change it in another name... And for the other entities, i would like to keep that automatic mapping (for the metadata's). 对于仅一个实体,我想配置“订单”列的名称,将其更改为其他名称...对于其他实体,我想保留该自动映射(对于元数据)。

So my question, is how could i do that ? 所以我的问题是,我该怎么办?

this the persistence-test.xml 这是persistence-test.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for dev profile -->
<persistence 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"
             version="1.0">

    <persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>

        <class>be.fed.minfin.adminctx.backend.model.MigrationProject</class>
        <class>be.fed.minfin.adminctx.backend.model.MigrationProperty</class>
        <class>be.fed.minfin.adminctx.backend.model.MigrationPropertyMappingValue</class>
        <class>be.fed.minfin.adminctx.backend.model.MigrationSearchProperty</class>
        <class>be.fed.minfin.adminctx.backend.model.ElementTravail</class>
        <class>be.fed.minfin.adminctx.backend.model.Litige</class>
        <class>be.fed.minfin.adminctx.backend.model.TraitementAdmin</class> 
        <class>be.fed.minfin.adminctx.backend.model.Cassation</class> 
        <class>be.fed.minfin.adminctx.backend.model.ExecutionJudiciaire</class> 
        <class>be.fed.minfin.adminctx.backend.model.LigneObjet</class> 
        <class>be.fed.minfin.adminctx.backend.model.Contribuable</class> 
        <class>be.fed.minfin.adminctx.backend.model.ProcedureJudiciaire</class> 
        <class>be.fed.minfin.adminctx.backend.model.TPI</class> 
        <class>be.fed.minfin.adminctx.backend.model.ArbitrageJustice</class> 
        <class>be.fed.minfin.adminctx.backend.model.IntervenantsAdmin</class> 
        <class>be.fed.minfin.adminctx.backend.model.Flux</class> 
        <class>be.fed.minfin.adminctx.backend.model.Article</class> 
        <class>be.fed.minfin.adminctx.backend.model.LigneAgenda</class> 
        <class>be.fed.minfin.adminctx.backend.model.Appel</class> 
        <class>be.fed.minfin.adminctx.backend.model.Assistance</class> 
        <class>be.fed.minfin.adminctx.backend.model.IntervenantsTaxation</class> 
        <class>be.fed.minfin.adminctx.backend.model.Reclamation</class> 
        <class>be.fed.minfin.adminctx.backend.model.Resume</class>
        <class>be.fed.minfin.adminctx.backend.model.DemandeAvocatTPI</class> 
        <class>be.fed.minfin.adminctx.backend.model.DemandeAvocatAppel</class> 
        <class>be.fed.minfin.adminctx.backend.model.ArretCassation</class> 
        <class>be.fed.minfin.adminctx.backend.model.IntervenantsTPI</class> 
        <class>be.fed.minfin.adminctx.backend.model.IntervenantsAssistance</class> 
        <class>be.fed.minfin.adminctx.backend.model.IntervenantsAppel</class> 
        <class>be.fed.minfin.adminctx.backend.model.IntervenantsExecution</class> 
        <class>be.fed.minfin.adminctx.backend.model.Mandataire</class> 
        <class>be.fed.minfin.adminctx.backend.model.IntervenantsArbitrage</class> 
        <class>be.fed.minfin.adminctx.backend.model.ArretArbitrageJustice</class> 
        <class>be.fed.minfin.adminctx.backend.model.ArretAppel</class> 
        <class>be.fed.minfin.adminctx.backend.model.IntervenantsResume</class> 
        <class>be.fed.minfin.adminctx.backend.model.RequeteAppel</class> 
        <class>be.fed.minfin.adminctx.backend.model.RequeteCassation</class> 
        <class>be.fed.minfin.adminctx.backend.model.Avocat</class> 
        <class>be.fed.minfin.adminctx.backend.model.JugementTPI</class> 
        <class>be.fed.minfin.adminctx.backend.model.IntervenantsJud</class> 
        <class>be.fed.minfin.adminctx.backend.model.Grief</class> 
        <class>be.fed.minfin.adminctx.backend.model.LitigeISI</class> 
        <class>be.fed.minfin.adminctx.backend.model.RequeteTPI</class> 
        <class>be.fed.minfin.adminctx.backend.model.IntervenantsCassation</class>
        <class>be.fed.minfin.adminctx.backend.model.HistMouvement</class>
        <class>be.fed.minfin.adminctx.backend.model.SIPTaxateurKey</class>
        <class>be.fed.minfin.adminctx.backend.model.SIPTaxateur</class>
        <class>be.fed.minfin.adminctx.backend.model.ServiceContentieux</class>


         <class>be.fed.minfin.adminctx.backend.model.AvocatEB</class>
         <class>be.fed.minfin.adminctx.backend.model.AvocatEBCassation</class>
         <class>be.fed.minfin.adminctx.backend.model.CoursAppel</class>
         <class>be.fed.minfin.adminctx.backend.model.Tribunal</class>
         <class>be.fed.minfin.adminctx.backend.model.Niveau</class> 


        <class>be.fed.minfin.adminctx.backend.model.LitigationReport</class>
        <class>be.fed.minfin.adminctx.backend.model.LitigationReportElement</class>
        <class>be.fed.minfin.adminctx.backend.model.LitigationReportElementType</class>

        <class>be.fed.minfin.adminctx.backend.model.views.ElementTravailIntervenantsView</class>

        <properties>
          <property name="openjpa.Log" value="DefaultLevel=INFO" /> 
          <property name="openjpa.Log" value="SQL=TRACE" />   
          <property name="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver" />
          <property name="openjpa.ConnectionURL" value="jdbc:hsqldb:mem:adminctxtest" />
          <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.HSQLDictionary"/>
          <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/> 

          <property name="hibernate.dialect" 
                  value="org.hibernate.dialect.HSQLDialect"/>
          <property name="hibernate.hbm2ddl.auto" value="create-drop"/>



        </properties>

    </persistence-unit>

</persistence>

this is the concerned entity (Niveau.java) 这是有关的实体(Niveau.java)

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@IdClass (NiveauPK.class)
@Table(name="CatDocumentTypeModeleLabelLevel")
@NamedQueries({ 

      @NamedQuery(name="SearchInAllLanguages", 
          query="SELECT n from Niveau n " +
              "WHERE n.sidNiveau = ?1 ")})
public class Niveau implements  ModelObject<Integer> , Serializable

{

    /**
     * 
     */
    private static final long serialVersionUID = 4407369231768353626L;


    @Column(name = "Level")
    protected Integer level;
    @Column(name = "Label")
    protected String label;
    @Id  
    //@GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "SIDCatDocumentTypeModeleLevel")
    protected Integer sidNiveau;
    @Id
    @Column(name ="Langue")
    protected String langue;
    @Column(name = "Order")
    protected Integer order;    
    /**
     * @Catalog: CatPhase
     */
    @Column(name = "Phase")
    protected Integer phase;
    /**
     * @Catalog: CatBoolean
     */
    @Column(name = "Visible")
    protected Boolean visible;


    @Override
    public Integer getId() {
        // TODO Auto-generated method stub
        return sidNiveau;
    }
    @Override
    public void setId(Integer id) {

        this.setId(sidNiveau);

    }
    public Integer getLevel() {
        return level;
    }
    public void setLevel(Integer level) {
        this.level = level;
    }
    public String getLabel() {
        return label;
    }
    public void setLabel(String label) {
        this.label = label;
    }
    public String getLangue() {
        return langue;
    }
    public void setLangue(String langue) {
        this.langue = langue;
    }
    public Integer getOrder() {
        return order;
    }
    public void setOrder(Integer order) {
        this.order = order;
    }
    public Integer getPhase() {
        return phase;
    }
    public void setPhase(Integer phase) {
        this.phase = phase;
    }
    public Boolean getVisible() {
        return visible;
    }
    public void setVisible(Boolean visible) {
        this.visible = visible;
    }
    public Integer getSidNiveau() {
        return sidNiveau;
    }
    public void setSidNiveau(Integer sidNiveau) {
        this.sidNiveau = sidNiveau;
    }
......

And this is how Dbunit creates the tables 这就是Dbunit创建表的方式

82  test  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.HSQLDictionary".
2250  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> executing prepstmnt 3534544 SELECT SEQUENCE_SCHEMA, SEQUENCE_NAME FROM INFORMATION_SCHEMA.SYSTEM_SEQUENCES
2250  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> [0 ms] spent
2254  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> executing stmnt 1247640 CREATE TABLE Appel (SIDAppel INTEGER NOT NULL, ArretCourant INTEGER, AudienceIntroDate TIMESTAMP, AudienceIntroResultat INTEGER, CassationArretInterlocutoire BIT, DateAcquiescementPA TIMESTAMP, DateConsultationPAEB TIMESTAMP, DateEnvoiPremiereCCLEB TIMESTAMP, DateIntroductionEB TIMESTAMP, DateIntroductionPA TIMESTAMP, DateOppositionEB TIMESTAMP, DateOppositionPA TIMESTAMP, DateReceptionRequetePA TIMESTAMP, DateSignificationArretEB TIMESTAMP, DateSignificationArretPA TIMESTAMP, Demande356 BIT, DirectionRegionale BIT, ExecArretType INTEGER, ExpirationDelaiCassation TIMESTAMP, ExpirationDelaiCassationEffect TIMESTAMP, IncidentEB BIT, IncidentPA BIT, InvitationTaxateur BIT, LitigePlaide BIT, NomCour INTEGER, NomCour2 INTEGER, NomCourRenvoi1 INTEGER, NomCourRenvoi2 INTEGER, ReAttributionMiseEnEtatAppel BIT, Requete356Signifiee BIT, RetourMiseEnEtatAppel BIT, SuiviArretType INTEGER, SIDLitige INTEGER, PRIMARY KEY (SIDAppel))
2254  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> [0 ms] spent
2255  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> executing stmnt 14662467 CREATE TABLE ArbitrageJustice (SIDArbitrageJustice INTEGER NOT NULL, ArretCourant INTEGER, Avocat2Nom INTEGER, Avocat2Reference VARCHAR(255), AvocatNom INTEGER, AvocatReference VARCHAR(255), DateNotificationGreffe TIMESTAMP, DateNotificationNotePA TIMESTAMP, LitigePlaide BIT, TypeCour INTEGER, SIDLitige INTEGER, PRIMARY KEY (SIDArbitrageJustice))
2255  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> [0 ms] spent
2255  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> executing stmnt 28301772 CREATE TABLE ArretAppel (SIDArretAppel INTEGER NOT NULL, Arret1Date TIMESTAMP, Arret1Resume INTEGER, Arret1ResumeEnCours BIT, Arret1Type1 INTEGER, Arret1Type2 INTEGER, Arret1Type3 INTEGER, Arret2Date TIMESTAMP, Arret2Resume INTEGER, Arret2ResumeEnCours BIT, Arret2Type1 INTEGER, Arret2Type2 INTEGER, Arret2Type3 INTEGER, Arret3Date TIMESTAMP, Arret3Resume INTEGER, Arret3ResumeEnCours BIT, Arret3Type1 INTEGER, Arret3Type2 INTEGER, Arret3Type3 INTEGER, Arret4Date TIMESTAMP, Arret4Resume INTEGER, Arret4ResumeEnCours BIT, Arret4Type1 INTEGER, Arret4Type2 INTEGER, Arret4Type3 INTEGER, Arret5Date TIMESTAMP, Arret5Resume INTEGER, Arret5ResumeEnCours BIT, Arret5Type1 INTEGER, Arret5Type2 INTEGER, Arret5Type3 INTEGER, SIDAppel INTEGER, PRIMARY KEY (SIDArretAppel))
2256  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> [1 ms] spent
2256  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> executing stmnt 9826960 CREATE TABLE ArretArbitrageJustice (SIDArretArbitrageJustice INTEGER NOT NULL, Arret1Cour INTEGER, Arret1Date TIMESTAMP, Arret1Resume INTEGER, Arret1ResumeEnCours BIT, Arret1Type INTEGER, Arret2Cour INTEGER, Arret2Date TIMESTAMP, Arret2Resume INTEGER, Arret2ResumeEnCours BIT, Arret2Type INTEGER, SIDArbitrageJustice INTEGER, PRIMARY KEY (SIDArretArbitrageJustice))
2256  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> [0 ms] spent
2256  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> executing stmnt 25250173 CREATE TABLE ArretCassation (SIDArretCassation INTEGER NOT NULL, Arret1Date TIMESTAMP, Arret1Resume INTEGER, Arret1ResumeEnCours BIT, Arret1Type1 INTEGER, Arret1Type2 INTEGER, Arret1Type3 INTEGER, Arret2Date TIMESTAMP, Arret2Resume INTEGER, Arret2ResumeEnCours BIT, Arret2Type1 INTEGER, Arret2Type2 INTEGER, Arret2Type3 INTEGER, Arret3Date TIMESTAMP, Arret3Resume INTEGER, Arret3ResumeEnCours BIT, Arret3Type1 INTEGER, Arret3Type2 INTEGER, Arret3Type3 INTEGER, SIDCassation INTEGER, PRIMARY KEY (SIDArretCassation))
2257  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> [1 ms] spent
2257  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> executing stmnt 11154712 CREATE TABLE Article (SIDArticle INTEGER NOT NULL, Art747par1 BIT, Art747par2DateNotification TIMESTAMP, Art747par2EB BIT, Art747par2PA BIT, Art748par2DateNotification TIMESTAMP, Art748par2EB BIT, Art748par2PA BIT, Art750par1 BIT, Art750par2DateNotification TIMESTAMP, Art750par2EB BIT, Art750par2PA BIT, Art751DateNotification TIMESTAMP, Art751EB BIT, Art751PA BIT, SIDLitige INTEGER, PRIMARY KEY (SIDArticle))
2257  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> [0 ms] spent
2257  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> executing stmnt 7272378 CREATE TABLE Assistance (SIDAssistance INTEGER NOT NULL, AppelAssistanceDemande BIT, AssistanceEnCours BIT, AssistanceTaxateur BIT, CommentaireSuivant VARCHAR(255), DemandeAssistanceAC BIT, DemandeModification BIT, ExecutionCommentaire VARCHAR(255), ExecutionType INTEGER, ReponseAC BIT, TPIAssistanceDemande BIT, SIDLitige INTEGER, PRIMARY KEY (SIDAssistance))
2258  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> [1 ms] spent
2258  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> executing stmnt 26757789 CREATE TABLE Avocat (SIDAvocat INTEGER NOT NULL, Adresse1 VARCHAR(255), Adresse1AvocatEpoux VARCHAR(255), Adresse2 VARCHAR(255), Adresse2AvocatEpoux VARCHAR(255), Adresse3 VARCHAR(255), Adresse3AvocatEpoux VARCHAR(255), AdressePays VARCHAR(255), AdressePaysAvocatEpoux VARCHAR(255), DateDeces TIMESTAMP, DateDecesEpoux TIMESTAMP, DateValidation TIMESTAMP, DateValidationEpoux TIMESTAMP, Email VARCHAR(255), EmailAvocatEpoux VARCHAR(255), GSM VARCHAR(255), GSMAvocatEpoux VARCHAR(255), Nom VARCHAR(255), NomAvocatEpoux VARCHAR(255), NumNational VARCHAR(255), NumNationalEpoux VARCHAR(255), PersIdf VARCHAR(255), PersIdfEpoux VARCHAR(255), Prenom VARCHAR(255), PrenomAvocatEpoux VARCHAR(255), ReferenceCourrier VARCHAR(255), ReferenceCourrierAvocatEpoux VARCHAR(255), StatutJuridique INTEGER, StatutJuridiqueEpoux INTEGER, StatutValidation BIT, StatutValidationEpoux BIT, Telephone VARCHAR(255), TelephoneAvocatEpoux VARCHAR(255), TvaCodePays VARCHAR(255), TvaCodePaysEpoux VARCHAR(255), TvaNumero VARCHAR(255), TvaNumeroEpoux VARCHAR(255), UpersIdf VARCHAR(255), UpersIdfEpoux VARCHAR(255), SIDContribuable INTEGER, PRIMARY KEY (SIDAvocat))
2258  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> [0 ms] spent
2259  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> executing stmnt 32316862 CREATE TABLE Cassation (SIDCassation INTEGER NOT NULL, ArretCourant INTEGER, AvocatNom INTEGER, AvocatReference VARCHAR(255), DateIntroductionEB TIMESTAMP, DateIntroductionPA TIMESTAMP, DateReceptionRequetePA TIMESTAMP, DateSignificationEB TIMESTAMP, DateSignificationPA TIMESTAMP, DateSignificationRequeteEB TIMESTAMP, DateSignificationRequetePA TIMESTAMP, DirectionRegionale BIT, ExecArretType INTEGER, SuiviArretType INTEGER, SIDLitige INTEGER, PRIMARY KEY (SIDCassation))
2259  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> [0 ms] spent
2259  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> executing stmnt 17691874 CREATE TABLE CatDocumentTypeModeleLabelLevel (Langue VARCHAR(255) NOT NULL, SIDCatDocumentTypeModeleLevel INTEGER NOT NULL, Label VARCHAR(255), Level INTEGER, Order INTEGER, Phase INTEGER, Visible BIT, PRIMARY KEY (Langue, SIDCatDocumentTypeModeleLevel))
2275  test  TRACE  [main] openjpa.jdbc.SQL - <t 13737183, conn 26350769> [16 ms] spent

Finally, i had found a solution to this problem. 最后,我找到了解决该问题的方法。 I am very late, but i have to share this. 我很晚了,但我必须分享。

As i may not change the structure of the database, i created a xml file for the table niveau (only used in my tests). 由于我可能不会更改数据库的结构,因此我为niveau表创建了一个xml文件(仅在测试中使用)。 In this file, i change the name of the column order in another name. 在此文件中,我将列顺序的名称更改为另一个名称。

So here are the steps. 所以这是步骤。

1) i create a xml file named "Niveau.xml" to map the fields of my table Niveau. 1)我创建一个名为“ Niveau.xml”的XML文件来映射我的表Niveau的字段。 And in this xml file, i changed the name of the column "order" in "ORDRE" 在这个xml文件中,我更改了“ ORDRE”中“ order”列的名称

entity-mappings is the tag to use for the mapping and you can see at the end of the file how i change the name of the column 实体映射是用于映射的标签,您可以在文件末尾看到我如何更改列名

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="1.0"
    xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd">

    <entity name="Niveau" class="be.fed.minfin.adminctx.backend.model.Niveau">
        <table name="Niveau" />
        <attributes>

            <id name="sidNiveau">

            </id>
            <id name="langue">

            </id> 

            <basic name="level">

            </basic>

            <basic name="visible">

            </basic>

            <basic name="order" >

                 <column name="ORDRE" />
            </basic>




        </attributes>
    </entity>
</entity-mappings>

2) Finally, i had to refer the file niveau.xml in the persistence-test.xml. 2)最后,我必须在persistence-test.xml中引用文件niveau.xml。

Instead of using the class Niveau for the mapping, i used the tag mapping-file . 我没有使用Niveau 进行映射,而是使用了标签mapping-file

So in my tests, the mapping "niveau.xml" (where the name of the column is correct) is used instead of the class entity "niveau.java" 因此,在我的测试中,使用映射“ niveau.xml”(其中列名正确)代替类实体“ niveau.java”

Here is a part of the persistence-test.xml 这是persistence-test.xml的一部分

<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for dev profile -->
<persistence 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"
             version="1.0">

    <persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>

        <mapping-file>niveau.xml</mapping-file>

        <class>be.fed.minfin.adminctx.backend.model.MigrationProject</class>
        <class>be.fed.minfin.adminctx.backend.model.MigrationProperty</class>
        <class>be.fed.minfin.adminctx.backend.model.MigrationPropertyMappingValue</class>
        <class>be.fed.minfin.adminctx.backend.model.MigrationSearchProperty</class>
        <class>be.fed.minfin.adminctx.backend.model.ElementTravail</class>
        <class>be.fed.minfin.adminctx.backend.model.Litige</class>
        <class>be.fed.minfin.adminctx.backend.model.TraitementAdmin</class> 
        <class>be.fed.minfin.adminctx.backend.model.Cassation</class> 
        <class>be.fed.minfin.adminctx.backend.model.ExecutionJudiciaire</class> 
        <class>be.fed.minfin.adminctx.backend.model.LigneObjet</class> 

This had resolved the problem with the column name "order" for my test. 这已经为我的测试解决了列名“ order”的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM