ORVE WS (Dynamic) (10) Persisting retrieved records and other control information (2). JPA definitions

0. Introduction

Up till now, the h2 database has been created and the schema SICRES30 too. Hibernate has been our JPA proposal.

Our goals are:

1. Create the persistence.xml file
2. Supply the JPA annotations to the classes to persist
3. Create the TABLES in the schema SICRES30


1. Creating persistence.xml file


As it is a Maven project, the persistence.xml fike should be created in the META-INF folder into the src/main/resources folder of our project


Here is the source code. Note the references to our database location, h2 driver etc.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
             version="2.1">
    
    <persistence-unit name="sicresh2" transaction-type="RESOURCE_LOCAL">
      <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
      
      <properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
   <property name="hibernate.hbm2ddl.auto" value="update" />
   <property name="hibernate.show_sql" value="true" />      
         <!-- BEGIN: DataSource By Hibernate (NO TOMCAT) -->
         <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/> 
         <property name="hibernate.connection.url" value="jdbc:h2:tcp://localhost/~/BDMeues/orve" />
   <property name="hibernate.connection.driver_class" value="org.h2.Driver" />
   <property name="hibernate.connection.username" value="orve" />
   <property name="hibernate.connection.password" value="mypassword" /> 
  <!-- END:   DataSource By Hibernate (NO TOMCAT)  -->
      </properties>

   </persistence-unit>
</persistence>


2. JPA annotations in classes


All the generated classes of ximodante.sicres.multiclass package, have been modified in this way:

  1.  The ximodante.sicres.multiclass package has been copied to ximodante.sicres.multiclassjpa
  2. All the XML comment stuff has been removed
  3. All setters and getters have been replaced with Lombok annotations @Getter and @Setter
  4. JPA @Entity annotation has been supplied
  5. All byte[] attributes have been added @Lob annotation as when this annotation is not present, the attribute is created as BINARY (255)
  6. Identity attribute "id" has been added to all the classes. These annotations have been added to this ide field:  @XmlTransient in order to be invisible to XML marshalling/unmarshalling, @Id and @GeneratedValue for JPA management.
  7. In any reference to a class (or list of classes) that has @Entity annotation for instance "FicherodeIntercambioSicres30.deOrigenORemitente"(marked with @OneToOne annotation) or "FicherodeIntercambioSicres30.deInteresado"(marked with @OneToMany annotation), the annotations (@OneToOne and  @OneToMany) must have a "cascade = CascadeType.ALL" element. Here is an example
    1
    2
    3
    4
    5
    6
    7
    @Getter @Setter
    @OneToOne(optional = true, cascade = CascadeType.ALL) // See https://stackoverflow.com/a/48876303/7704658
    protected DeOrigenORemitente deOrigenORemitente;
    
    @Getter @Setter
    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
    protected List<DeInteresado> deInteresado;
    
  8. Classes that have fields that cannot have duplicated values, the field should have the @Column(unique=true) annotation. It can also be specified with a class annotation @Table(uniqueConstraints = @UniqueConstraint(columnNames = {"myAttribute", })
        

  

In order to know if a record has been persisted form WS information, there are 2 ways of identifying a record:

  1. By the "items" returned by the WS function "obtenerIdentificadores".
  2. By the unique key  ("DeOrigenORemitente.numeroRegistroEntrada") where the class is DeOrigenORemitente and the attribute is numeroRegistroEntrada.

It is interesting having both identifying systems.

For the first one, it can be accomplished by creating a field "item" that is invisible to XML (@XmlTransient) in the class FicherodeIntercambioSicres30 "FicherodeIntercambioSicres30.item".  So it means two actions, creating the new field and using a Table annotation with unique constraints field:

@XmlTransient  //  Invisible or transient in XML
@Getter @Setter
protected int item

---

@Table(name = "FICHEROINTERCAMBIOSICRES30", schema = "SICRES30" 
      ,uniqueConstraints = @UniqueConstraint(columnNames =  { "item", })
      // ,indexes = {@Index (name = "idx_usuari_entityadm", columnList = "usuari, entityAdm")}
      )


For the second one it can be defined a @Table annotation as follows:

@Table(name = "DEORIGENOREMITENTE", schema = "SICRES30"
       , uniqueConstraints = @UniqueConstraint(columnNames =  { "numeroRegistroEntrada" })
      //, indexes = {@Index (name = "idx_usuari_entityadm", columnList = "usuari, entityAdm")}
      )

Here is the java code for these classes displayed alphabetically:

DeAnexo class:


  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
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
package ximodante.sicres.multiclassjpa;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "nombreFicheroAnexado", "identificadorFichero", "validezDocumento", "tipoDocumento",
  "certificado", "firmaDocumento", "timeStamp", "validacionOCSPCertificado", "hash", "tipoMIME", "anexo",
  "identificadorDocumentoFirmado", "observaciones" })

@Entity
@Table(name = "DEANEXO", schema = "SICRES30"
// ,uniqueConstraints = @UniqueConstraint(columnNames = { "programa", "usuari",
// "entityadm", }),
// indexes = {@Index (name = "idx_usuari_entityadm", columnList = "usuari,
// entityAdm")}
)
//@Audited
@ToString
@NoArgsConstructor
public class DeAnexo {

 @XmlTransient
 @Getter @Setter
 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 protected long id;

 @XmlElement(name = "Nombre_Fichero_Anexado", required = true)
 @Getter @Setter
 protected String nombreFicheroAnexado;

 @XmlElement(name = "Identificador_Fichero", required = true)
 @Getter @Setter
 protected String identificadorFichero;

 @XmlElement(name = "Validez_Documento")
 @Getter @Setter
 protected String validezDocumento;

 @XmlElement(name = "Tipo_Documento", required = true)
 @Getter @Setter
 protected String tipoDocumento;

 @XmlElement(name = "Certificado")
 @Getter @Setter
 @Lob
 protected byte[] certificado;

 @XmlElement(name = "Firma_Documento")
 @Getter @Setter
 @Lob
 protected byte[] firmaDocumento;

 @XmlElement(name = "TimeStamp")
 @Getter @Setter
 @Lob
 protected byte[] timeStamp;

 @XmlElement(name = "Validacion_OCSP_Certificado")
 @Getter @Setter
 @Lob
 protected byte[] validacionOCSPCertificado;

 @XmlElement(name = "Hash", required = true)
 @Getter @Setter
 @Lob
 protected byte[] hash;

 @XmlElement(name = "Tipo_MIME")
 @Getter @Setter
 protected String tipoMIME;

 @XmlElement(name = "Anexo")
 @Getter @Setter
 @Lob
 protected byte[] anexo;

 @XmlElement(name = "Identificador_Documento_Firmado")
 @Getter @Setter
 protected String identificadorDocumentoFirmado;

 @XmlElement(name = "Observaciones")
 @Getter @Setter
 protected String observaciones;

}


DeAsunto class:


 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
55
56
package ximodante.sicres.multiclassjpa;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "resumen", "codigoAsuntoSegunDestino", "referenciaExterna", "numeroExpediente" })

@Entity
@Table(name = "DEASUNTO", schema = "SICRES30"
// ,uniqueConstraints = @UniqueConstraint(columnNames = { "programa", "usuari",
// "entityadm", }),
// indexes = {@Index (name = "idx_usuari_entityadm", columnList = "usuari,
// entityAdm")}
)
//@Audited
@ToString
@NoArgsConstructor
public class DeAsunto {

 @XmlTransient
 @Getter @Setter
 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 protected long id;

 @XmlElement(name = "Resumen", required = true)
 @Getter @Setter
 protected String resumen;

 @XmlElement(name = "Codigo_Asunto_Segun_Destino")
 @Getter @Setter
 protected String codigoAsuntoSegunDestino;

 @XmlElement(name = "Referencia_Externa")
 @Getter @Setter
 protected String referenciaExterna;

 @XmlElement(name = "Numero_Expediente")
 @Getter @Setter
 protected String numeroExpediente;

}


DeDestino class:


 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
55
package ximodante.sicres.multiclassjpa;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "codigoEntidadRegistralDestino", "decodificacionEntidadRegistralDestino",
  "codigoUnidadTramitacionDestino", "decodificacionUnidadTramitacionDestino" })
@Entity
@Table(name = "DEDESTINO", schema = "SICRES30"
// ,uniqueConstraints = @UniqueConstraint(columnNames = { "programa", "usuari",
// "entityadm", }),
// indexes = {@Index (name = "idx_usuari_entityadm", columnList = "usuari,
// entityAdm")}
)
//@Audited
@ToString
@NoArgsConstructor
public class DeDestino {

 @XmlTransient
 @Getter @Setter
 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 protected long id;

 @XmlElement(name = "Codigo_Entidad_Registral_Destino", required = true)
 @Getter @Setter
 protected String codigoEntidadRegistralDestino;

 @XmlElement(name = "Decodificacion_Entidad_Registral_Destino")
 @Getter @Setter
 protected String decodificacionEntidadRegistralDestino;

 @XmlElement(name = "Codigo_Unidad_Tramitacion_Destino")
 @Getter @Setter
 protected String codigoUnidadTramitacionDestino;

 @XmlElement(name = "Decodificacion_Unidad_Tramitacion_Destino")
 @Getter @Setter
 protected String decodificacionUnidadTramitacionDestino;
}


DeFormularioGenercio class:


 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
package ximodante.sicres.multiclassjpa;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "expone", "solicita" })
@Entity
@Table(name = "DEFORMULARIOGENERICO", schema = "SICRES30"
// ,uniqueConstraints = @UniqueConstraint(columnNames = { "programa", "usuari",
// "entityadm", }),
// indexes = {@Index (name = "idx_usuari_entityadm", columnList = "usuari,
// entityAdm")}
)
//@Audited
@ToString
@NoArgsConstructor

public class DeFormularioGenerico {

 @XmlTransient
 @Getter @Setter
 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 protected long id;

 @XmlElement(name = "Expone", required = true)
 @Getter @Setter
 protected String expone;

 @XmlElement(name = "Solicita", required = true)
 @Getter @Setter
 protected String solicita;
}


DeInteresado class:


  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
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package ximodante.sicres.multiclassjpa;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "tipoDocumentoIdentificacionInteresado", "documentoIdentificacionInteresado",
  "razonSocialInteresado", "nombreInteresado", "primerApellidoInteresado", "segundoApellidoInteresado",
  "tipoDocumentoIdentificacionRepresentante", "documentoIdentificacionRepresentante", "razonSocialRepresentante",
  "nombreRepresentante", "primerApellidoRepresentante", "segundoApellidoRepresentante", "paisInteresado",
  "provinciaInteresado", "municipioInteresado", "direccionInteresado", "codigoPostalInteresado",
  "correoElectronicoInteresado", "telefonoContactoInteresado", "direccionElectronicaHabilitadaInteresado",
  "canalPreferenteComunicacionInteresado", "paisRepresentante", "provinciaRepresentante",
  "municipioRepresentante", "direccionRepresentante", "codigoPostalRepresentante",
  "correoElectronicoRepresentante", "telefonoContactoRepresentante",
  "direccionElectronicaHabilitadaRepresentante", "canalPreferenteComunicacionRepresentante", "observaciones" })
@Entity
@Table(name = "DEINTERESADO", schema = "SICRES30"
// ,uniqueConstraints = @UniqueConstraint(columnNames = { "programa", "usuari",
// "entityadm", }),
// indexes = {@Index (name = "idx_usuari_entityadm", columnList = "usuari,
// entityAdm")}
)
//@Audited
@ToString
@NoArgsConstructor

public class DeInteresado {

 @XmlTransient
 @Getter @Setter
 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 protected long id;

 @XmlElement(name = "Tipo_Documento_Identificacion_Interesado")
 @Getter @Setter
 protected String tipoDocumentoIdentificacionInteresado;

 @XmlElement(name = "Documento_Identificacion_Interesado")
 @Getter @Setter
 protected String documentoIdentificacionInteresado;

 @XmlElement(name = "Razon_Social_Interesado")
 @Getter @Setter
 protected String razonSocialInteresado;

 @XmlElement(name = "Nombre_Interesado")
 @Getter @Setter
 protected String nombreInteresado;

 @XmlElement(name = "Primer_Apellido_Interesado")
 @Getter @Setter
 protected String primerApellidoInteresado;

 @XmlElement(name = "Segundo_Apellido_Interesado")
 @Getter @Setter
 protected String segundoApellidoInteresado;

 @XmlElement(name = "Tipo_Documento_Identificacion_Representante")
 @Getter @Setter
 protected String tipoDocumentoIdentificacionRepresentante;

 @XmlElement(name = "Documento_Identificacion_Representante")
 @Getter @Setter
 protected String documentoIdentificacionRepresentante;

 @XmlElement(name = "Razon_Social_Representante")
 @Getter @Setter
 protected String razonSocialRepresentante;

 @XmlElement(name = "Nombre_Representante")
 @Getter @Setter
 protected String nombreRepresentante;

 @XmlElement(name = "Primer_Apellido_Representante")
 @Getter @Setter
 protected String primerApellidoRepresentante;

 @XmlElement(name = "Segundo_Apellido_Representante")
 @Getter @Setter
 protected String segundoApellidoRepresentante;

 @XmlElement(name = "Pais_Interesado")
 @Getter @Setter
 protected String paisInteresado;

 @XmlElement(name = "Provincia_Interesado")
 @Getter @Setter
 protected String provinciaInteresado;

 @XmlElement(name = "Municipio_Interesado")
 @Getter @Setter
 protected String municipioInteresado;

 @XmlElement(name = "Direccion_Interesado")
 @Getter @Setter
 protected String direccionInteresado;

 @XmlElement(name = "Codigo_Postal_Interesado")
 @Getter @Setter
 protected String codigoPostalInteresado;

 @XmlElement(name = "Correo_Electronico_Interesado")
 @Getter @Setter
 protected String correoElectronicoInteresado;

 @XmlElement(name = "Telefono_Contacto_Interesado")
 @Getter @Setter
 protected String telefonoContactoInteresado;

 @XmlElement(name = "Direccion_Electronica_Habilitada_Interesado")
 @Getter @Setter
 protected String direccionElectronicaHabilitadaInteresado;

 @XmlElement(name = "Canal_Preferente_Comunicacion_Interesado")
 @Getter @Setter
 protected String canalPreferenteComunicacionInteresado;

 @XmlElement(name = "Pais_Representante")
 @Getter @Setter
 protected String paisRepresentante;

 @XmlElement(name = "Provincia_Representante")
 @Getter @Setter
 protected String provinciaRepresentante;

 @XmlElement(name = "Municipio_Representante")
 @Getter @Setter
 protected String municipioRepresentante;

 @XmlElement(name = "Direccion_Representante")
 @Getter @Setter
 protected String direccionRepresentante;

 @XmlElement(name = "Codigo_Postal_Representante")
 @Getter @Setter
 protected String codigoPostalRepresentante;

 @XmlElement(name = "Correo_Electronico_Representante")
 @Getter @Setter
 protected String correoElectronicoRepresentante;

 @XmlElement(name = "Telefono_Contacto_Representante")
 @Getter @Setter
 protected String telefonoContactoRepresentante;

 @XmlElement(name = "Direccion_Electronica_Habilitada_Representante")
 @Getter @Setter
 protected String direccionElectronicaHabilitadaRepresentante;

 @XmlElement(name = "Canal_Preferente_Comunicacion_Representante")
 @Getter @Setter
 protected String canalPreferenteComunicacionRepresentante;

 @XmlElement(name = "Observaciones")
 @Getter @Setter
 protected String observaciones;

}


DeInternosControl class:


 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package ximodante.sicres.multiclassjpa;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "tipoTransporteEntrada", "numeroTransporteEntrada", "nombreUsuario",
  "contactoUsuario", "identificadorIntercambio", "aplicacionVersionEmisora", "tipoAnotacion",
  "descripcionTipoAnotacion", "tipoRegistro", "documentacionFisica", "observacionesApunte", "indicadorPrueba",
  "codigoEntidadRegistralInicio", "decodificacionEntidadRegistralInicio" })
@Entity
@Table(name = "DEINTERNOSCONTROL", schema = "SICRES30"
// ,uniqueConstraints = @UniqueConstraint(columnNames = { "programa", "usuari",
// "entityadm", }),
// indexes = {@Index (name = "idx_usuari_entityadm", columnList = "usuari,
// entityAdm")}
)
//@Audited
@ToString
@NoArgsConstructor
public class DeInternosControl {

 @XmlTransient
 @Getter @Setter
 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 protected long id;

 @XmlElement(name = "Tipo_Transporte_Entrada")
 @Getter @Setter
 protected String tipoTransporteEntrada;

 @XmlElement(name = "Numero_Transporte_Entrada")
 @Getter @Setter
 protected String numeroTransporteEntrada;

 @XmlElement(name = "Nombre_Usuario")
 @Getter @Setter
 protected String nombreUsuario;

 @XmlElement(name = "Contacto_Usuario")
 @Getter @Setter
 protected String contactoUsuario;

 @XmlElement(name = "Identificador_Intercambio", required = true)
 @Getter @Setter
 protected String identificadorIntercambio;

 @XmlElement(name = "Aplicacion_Version_Emisora")
 @Getter @Setter
 protected String aplicacionVersionEmisora;

 @XmlElement(name = "Tipo_Anotacion", required = true)
 @Getter @Setter
 protected String tipoAnotacion;

 @XmlElement(name = "Descripcion_Tipo_Anotacion")
 @Getter @Setter
 protected String descripcionTipoAnotacion;

 @XmlElement(name = "Tipo_Registro", required = true)
 @Getter @Setter
 protected String tipoRegistro;

 @XmlElement(name = "Documentacion_Fisica", required = true)
 @Getter @Setter
 protected String documentacionFisica;

 @XmlElement(name = "Observaciones_Apunte")
 @Getter @Setter
 protected String observacionesApunte;

 @XmlElement(name = "Indicador_Prueba", required = true)
 @Getter @Setter
 protected String indicadorPrueba;

 @XmlElement(name = "Codigo_Entidad_Registral_Inicio", required = true)
 @Getter @Setter
 protected String codigoEntidadRegistralInicio;

 @XmlElement(name = "Decodificacion_Entidad_Registral_Inicio")
 @Getter @Setter
 protected String decodificacionEntidadRegistralInicio;

}


DeOrigenORemitente class:


 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package ximodante.sicres.multiclassjpa;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "codigoEntidadRegistralOrigen", "decodificacionEntidadRegistralOrigen",
  "numeroRegistroEntrada", "fechaHoraEntrada", "timestampEntrada", "codigoUnidadTramitacionOrigen",
  "decodificacionUnidadTramitacionOrigen" })
@Entity
@Table(name = "DEORIGENOREMITENTE", schema = "SICRES30", uniqueConstraints = @UniqueConstraint(columnNames = {
  "numeroRegistroEntrada" })
// , indexes = {@Index (name = "idx_usuari_entityadm", columnList = "usuari,
// entityAdm")}
)
//@Audited
@ToString
@NoArgsConstructor
public class DeOrigenORemitente {
 // Not marshaled in XML
 @XmlTransient
 @Getter @Setter
 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 protected long id;

 @XmlElement(name = "Codigo_Entidad_Registral_Origen", required = true)
 @Getter @Setter
 protected String codigoEntidadRegistralOrigen;

 @XmlElement(name = "Decodificacion_Entidad_Registral_Origen")
 @Getter @Setter
 protected String decodificacionEntidadRegistralOrigen;

 @XmlElement(name = "Numero_Registro_Entrada", required = true)
 @Getter @Setter
 protected String numeroRegistroEntrada;

 @XmlElement(name = "Fecha_Hora_Entrada", required = true)
 @Getter @Setter
 protected String fechaHoraEntrada;

 @XmlElement(name = "Timestamp_Entrada")
 @Getter @Setter
 @Lob
 protected byte[] timestampEntrada;

 @XmlElement(name = "Codigo_Unidad_Tramitacion_Origen")
 @Getter @Setter
 protected String codigoUnidadTramitacionOrigen;

 @XmlElement(name = "Decodificacion_Unidad_Tramitacion_Origen")
 @Getter @Setter
 protected String decodificacionUnidadTramitacionOrigen;
}


And finally the main class FicheroIntercambioSicres3 class:


 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package ximodante.sicres.multiclassjpa;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "deOrigenORemitente", "deDestino", "deInteresado", "deAsunto", "deAnexo",
  "deInternosControl", "deFormularioGenerico" })
@XmlRootElement(name = "Fichero_Intercambio_SICRES_3")

@Entity
@Table(name = "FICHEROINTERCAMBIOSICRES30", schema = "SICRES30", uniqueConstraints = @UniqueConstraint(columnNames = {
  "item", })
// ,indexes = {@Index (name = "idx_usuari_entityadm", columnList = "usuari,
// entityAdm")}
)
//@Audited
@ToString
@NoArgsConstructor

public class FicheroIntercambioSICRES3 {

 @XmlTransient // Invisible or transient in XML
 @Getter @Setter
 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 protected long id;

 @XmlTransient // Invisible or transient in XML
 @Getter @Setter
 protected int item;

 @XmlElement(name = "De_Origen_o_Remitente", required = true)
 @Getter @Setter
 @OneToOne(optional = true) // See https://stackoverflow.com/a/48876303/7704658
 protected DeOrigenORemitente deOrigenORemitente;

 @XmlElement(name = "De_Destino", required = true)
 @Getter @Setter
 @OneToOne(optional = true) // See https://stackoverflow.com/a/48876303/7704658
 protected DeDestino deDestino;

 @XmlElement(name = "De_Interesado", required = true)
 @Getter @Setter
 @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
 protected List<DeInteresado> deInteresado;

 @XmlElement(name = "De_Asunto", required = true)
 @Getter @Setter
 @OneToOne(optional = true) // See https://stackoverflow.com/a/48876303/7704658
 protected DeAsunto deAsunto;

 @XmlElement(name = "De_Anexo")
 @Getter @Setter
 @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
 protected List<DeAnexo> deAnexo;

 @XmlElement(name = "De_Internos_Control", required = true)
 @Getter @Setter
 @OneToOne(optional = true) // See https://stackoverflow.com/a/48876303/7704658
 protected DeInternosControl deInternosControl;

 @XmlElement(name = "De_Formulario_Generico", required = true)
 @Getter @Setter
 @OneToOne(optional = true) // See https://stackoverflow.com/a/48876303/7704658
 protected DeFormularioGenerico deFormularioGenerico;

}




Comments

Popular posts from this blog

ORVE WS (Dynamic) (4) Jackson XML mapper

ENI (1) ENI Document OR the Spanish Electronic Administration Mafia

ORVE WS (Dynamic) (12) Defiining the control tables