diff --git a/pom.xml b/pom.xml
index da434cd..ce858ef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,9 +24,9 @@
3.0.1-b06
3.0.1-b12
2.4.0-b180830.0359
- 6.0.10.Final
+ 6.2.3.Final
1.3
- 42.4.2
+ 42.7.3
2.0.2
1.7.0
@@ -34,7 +34,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.7.18
+ 3.2.4
@@ -115,7 +115,7 @@
org.hibernate.search
- hibernate-search-mapper-orm
+ hibernate-search-mapper-orm-orm6
${hibernate.search.orm.version}
@@ -123,11 +123,6 @@
hibernate-search-backend-lucene
${hibernate.search.orm.version}
-
- org.hibernate.search
- hibernate-search-v5migrationhelper-orm
- ${hibernate.search.orm.version}
-
org.hamcrest
@@ -174,7 +169,7 @@
com.fasterxml.jackson.datatype
- jackson-datatype-hibernate5
+ jackson-datatype-hibernate6
${jackson.version}
@@ -259,67 +254,5 @@
-
- gcp
-
-
-
- org.springframework.cloud
- spring-cloud-gcp-dependencies
- 1.2.7.RELEASE
- pom
- import
-
-
-
-
-
- org.springframework
- spring-context-indexer
- true
-
-
- com.h2database
- h2
- ${h2.version}
-
-
- org.springframework.cloud
- spring-cloud-gcp-starter-sql-postgresql
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
- repackage
-
-
-
-
-
- com.google.cloud.tools
- appengine-maven-plugin
- 2.4.0
-
- sepomex-api
- 3
-
-
-
-
-
- src/main/resources
-
- application.properties
-
-
-
-
-
diff --git a/src/main/java/com/perales/sepomex/Application.java b/src/main/java/com/perales/sepomex/Application.java
index 8548333..6ddc076 100644
--- a/src/main/java/com/perales/sepomex/Application.java
+++ b/src/main/java/com/perales/sepomex/Application.java
@@ -1,7 +1,7 @@
package com.perales.sepomex;
import com.fasterxml.jackson.databind.Module;
-import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
+import com.fasterxml.jackson.datatype.hibernate6.Hibernate6Module;
import lombok.extern.log4j.Log4j2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -30,6 +30,6 @@ public void addCorsMappings(CorsRegistry registry) {
@Bean
public Module datatypeHibernateModule() {
log.info("Cargando modulo hibernate jackson");
- return new Hibernate5Module();
+ return new Hibernate6Module();
}
}
\ No newline at end of file
diff --git a/src/main/java/com/perales/sepomex/controller/AsentamientoTipoController.java b/src/main/java/com/perales/sepomex/controller/AsentamientoTipoController.java
index 051a87c..f4f035e 100644
--- a/src/main/java/com/perales/sepomex/controller/AsentamientoTipoController.java
+++ b/src/main/java/com/perales/sepomex/controller/AsentamientoTipoController.java
@@ -42,9 +42,4 @@ public AsentamientoTipo actualizar( @RequestBody AsentamientoTipo entity) {
public AsentamientoTipo borrar( @PathVariable Integer id) {
return asentamientoTipoService.borrar(id);
}
-
- @GetMapping(value = "/name/{name}")
- public List searchByName(@PathVariable String name) {
- return asentamientoTipoService.searchByName(name);
- }
}
diff --git a/src/main/java/com/perales/sepomex/controller/CiudadController.java b/src/main/java/com/perales/sepomex/controller/CiudadController.java
index a9a101d..9518779 100644
--- a/src/main/java/com/perales/sepomex/controller/CiudadController.java
+++ b/src/main/java/com/perales/sepomex/controller/CiudadController.java
@@ -43,9 +43,4 @@ public Ciudad actualizar(@Validated @RequestBody Ciudad entity) {
public Ciudad borrar(@PathVariable Integer id) {
return ciudadService.borrar(id);
}
-
- @GetMapping(value = "/name/{name}")
- public List searchByName(@PathVariable String name) {
- return ciudadService.searchByName(name);
- }
}
diff --git a/src/main/java/com/perales/sepomex/controller/CodigoPostalController.java b/src/main/java/com/perales/sepomex/controller/CodigoPostalController.java
index 6ff5b43..650ba5e 100644
--- a/src/main/java/com/perales/sepomex/controller/CodigoPostalController.java
+++ b/src/main/java/com/perales/sepomex/controller/CodigoPostalController.java
@@ -47,9 +47,4 @@ public CodigoPostal actualizar(@Validated @RequestBody CodigoPostal entity) {
public CodigoPostal borrar(@PathVariable Integer id) {
return codigoPostalService.borrar(id.longValue());
}
-
- @GetMapping(value = "/name/{name}")
- public List searchByName(@PathVariable String name) {
- return codigoPostalService.searchByName(name);
- }
}
diff --git a/src/main/java/com/perales/sepomex/controller/EstadoController.java b/src/main/java/com/perales/sepomex/controller/EstadoController.java
index 9a3afb0..367d675 100644
--- a/src/main/java/com/perales/sepomex/controller/EstadoController.java
+++ b/src/main/java/com/perales/sepomex/controller/EstadoController.java
@@ -43,9 +43,5 @@ public Estado actualizar(@Validated @RequestBody Estado entity) {
public Estado borrar(@PathVariable Integer id) {
return estadoService.borrar(id);
}
-
- @GetMapping(value = "/name/{name}")
- public List searchByName(@PathVariable String name) {
- return estadoService.searchByName(name);
- }
+
}
diff --git a/src/main/java/com/perales/sepomex/controller/InegiClaveCiudadController.java b/src/main/java/com/perales/sepomex/controller/InegiClaveCiudadController.java
index aa01bc4..2bf33c9 100644
--- a/src/main/java/com/perales/sepomex/controller/InegiClaveCiudadController.java
+++ b/src/main/java/com/perales/sepomex/controller/InegiClaveCiudadController.java
@@ -43,9 +43,4 @@ public InegiClaveCiudad actualizar(@Validated @RequestBody InegiClaveCiudad enti
public InegiClaveCiudad borrar(@PathVariable Integer id) {
return inegiClaveCiudadService.borrar(id);
}
-
- @GetMapping(value = "/name/{name}")
- public List searchByName(@PathVariable String name) {
- return inegiClaveCiudadService.searchByName(name);
- }
}
diff --git a/src/main/java/com/perales/sepomex/controller/InegiClaveMunicipioController.java b/src/main/java/com/perales/sepomex/controller/InegiClaveMunicipioController.java
index e2f3879..680b528 100644
--- a/src/main/java/com/perales/sepomex/controller/InegiClaveMunicipioController.java
+++ b/src/main/java/com/perales/sepomex/controller/InegiClaveMunicipioController.java
@@ -43,9 +43,5 @@ public InegiClaveMunicipio actualizar(@Validated @RequestBody InegiClaveMunicipi
public InegiClaveMunicipio borrar(@PathVariable Integer id) {
return inegiClaveMunicipioService.borrar(id);
}
-
- @GetMapping(value = "/name/{name}")
- public List searchByName(@PathVariable String name) {
- return inegiClaveMunicipioService.searchByName(name);
- }
+
}
diff --git a/src/main/java/com/perales/sepomex/controller/MunicipioController.java b/src/main/java/com/perales/sepomex/controller/MunicipioController.java
index f166b68..bddcc6e 100644
--- a/src/main/java/com/perales/sepomex/controller/MunicipioController.java
+++ b/src/main/java/com/perales/sepomex/controller/MunicipioController.java
@@ -47,9 +47,4 @@ public Municipio borrar( @PathVariable Integer id) {
public Page findByEstadoId( @PathVariable Integer id, @RequestParam int page, @RequestParam int size) {
return municipioService.findByEstadoId(id, page, size);
}
-
- @GetMapping(value = "/name/{name}")
- public List searchByName(@PathVariable String name) {
- return municipioService.searchByName(name);
- }
}
diff --git a/src/main/java/com/perales/sepomex/controller/ZonaTipoController.java b/src/main/java/com/perales/sepomex/controller/ZonaTipoController.java
index 61e7908..630e3d0 100644
--- a/src/main/java/com/perales/sepomex/controller/ZonaTipoController.java
+++ b/src/main/java/com/perales/sepomex/controller/ZonaTipoController.java
@@ -43,9 +43,4 @@ public ZonaTipo actualizar(@Validated @RequestBody ZonaTipo entity) {
public ZonaTipo borrar(@PathVariable Integer id) {
return zonaTipoService.borrar(id);
}
-
- @GetMapping(value = "/name/{name}")
- public List searchByName(@PathVariable String name) {
- return zonaTipoService.searchByName(name);
- }
}
diff --git a/src/main/java/com/perales/sepomex/model/Archivo.java b/src/main/java/com/perales/sepomex/model/Archivo.java
index f81bb21..866bad1 100644
--- a/src/main/java/com/perales/sepomex/model/Archivo.java
+++ b/src/main/java/com/perales/sepomex/model/Archivo.java
@@ -1,12 +1,8 @@
package com.perales.sepomex.model;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
import java.time.LocalDateTime;
import java.util.Objects;
+import jakarta.persistence.*;
@Entity(name = "archivo")
public class Archivo {
diff --git a/src/main/java/com/perales/sepomex/model/AsentamientoTipo.java b/src/main/java/com/perales/sepomex/model/AsentamientoTipo.java
index b145669..9b27f35 100644
--- a/src/main/java/com/perales/sepomex/model/AsentamientoTipo.java
+++ b/src/main/java/com/perales/sepomex/model/AsentamientoTipo.java
@@ -4,13 +4,15 @@
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
+import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
-import org.hibernate.search.annotations.*;
+import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
+import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
+import org.hibernate.search.engine.backend.types.TermVector;
-import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@@ -18,40 +20,33 @@
@Indexed
@Data
-@EqualsAndHashCode( exclude = { "id","colonias"})
+@EqualsAndHashCode(exclude = {"id", "colonias"})
@NoArgsConstructor
-@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
+@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@Entity(name = "asentamiento_tipo")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class AsentamientoTipo implements Serializable {
-
+
private static final long serialVersionUID = 3547469072116532512L;
+
@Id
- @GeneratedValue(
- generator = "sequence_asentamiento_tipo",
- strategy = GenerationType.SEQUENCE
- )
- @SequenceGenerator(
- name = "sequence_asentamiento_tipo",
- allocationSize = 10
- )
+ @GeneratedValue(generator = "sequence_asentamiento_tipo", strategy = GenerationType.SEQUENCE)
+ @SequenceGenerator(name = "sequence_asentamiento_tipo", allocationSize = 10)
@Column(name = "id")
private Integer id;
-
- @Field(store = Store.YES)
- @Field(name = "asentamientoTipoEs_beginEnd", store = Store.YES, analyzer = @Analyzer(definition = "es_beginEnd"))
+ @GenericField
@NotNull
@NotBlank
@Column(name = "nombre", nullable = false)
private String nombre;
-
- @Field(termVector = TermVector.YES)
+
+ @FullTextField(termVector = TermVector.YES)
@NotNull
@NotBlank
@Column(name = "sepomex_clave", nullable = false)
private String sepomexClave;
-
- @OneToMany(mappedBy = "asentamientoTipo", fetch = FetchType.LAZY )
+
+ @OneToMany(mappedBy = "asentamientoTipo", fetch = FetchType.LAZY)
private List colonias;
}
diff --git a/src/main/java/com/perales/sepomex/model/Ciudad.java b/src/main/java/com/perales/sepomex/model/Ciudad.java
index a738ff0..173b722 100644
--- a/src/main/java/com/perales/sepomex/model/Ciudad.java
+++ b/src/main/java/com/perales/sepomex/model/Ciudad.java
@@ -3,15 +3,16 @@
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
+import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
-import org.hibernate.search.annotations.Analyzer;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.Store;
+import org.apache.lucene.document.Field;
+import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
+import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
-import javax.persistence.*;
+
+import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
@@ -37,11 +38,11 @@ public class Ciudad implements Serializable {
)
@Column(name = "id")
private Integer id;
-
- @Field(store = Store.YES)
- @Field(name = "ciudadEs_beginEnd", store = Store.YES, analyzer = @Analyzer(definition = "es_beginEnd"))
+
+ @FullTextField(analyzer = "es_beginEnd")
@NotNull
+ @NotBlank
@Column(name = "nombre", nullable = false)
private String nombre;
diff --git a/src/main/java/com/perales/sepomex/model/CodigoPostal.java b/src/main/java/com/perales/sepomex/model/CodigoPostal.java
index 4d00afe..aee38d5 100644
--- a/src/main/java/com/perales/sepomex/model/CodigoPostal.java
+++ b/src/main/java/com/perales/sepomex/model/CodigoPostal.java
@@ -1,13 +1,15 @@
package com.perales.sepomex.model;
import com.fasterxml.jackson.annotation.*;
+import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.TermVector;
-import javax.persistence.*;
+import org.hibernate.search.engine.backend.types.TermVector;
+import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
+import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
+
+
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@@ -38,7 +40,7 @@ public class CodigoPostal implements Serializable {
@Column(name = "id")
private Long id;
- @Field(termVector = TermVector.YES)
+ @FullTextField(termVector = TermVector.YES)
@NotNull
@NotBlank
@Column(name = "nombre", nullable = false)
diff --git a/src/main/java/com/perales/sepomex/model/Colonia.java b/src/main/java/com/perales/sepomex/model/Colonia.java
index 528753d..c09766e 100644
--- a/src/main/java/com/perales/sepomex/model/Colonia.java
+++ b/src/main/java/com/perales/sepomex/model/Colonia.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
+import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@@ -10,7 +11,6 @@
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
-import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
diff --git a/src/main/java/com/perales/sepomex/model/Estado.java b/src/main/java/com/perales/sepomex/model/Estado.java
index 9876b6d..2c25195 100644
--- a/src/main/java/com/perales/sepomex/model/Estado.java
+++ b/src/main/java/com/perales/sepomex/model/Estado.java
@@ -3,14 +3,16 @@
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
+import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
-import org.hibernate.search.annotations.*;
+import org.hibernate.search.engine.backend.types.TermVector;
+import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
-import javax.persistence.*;
+
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@@ -37,16 +39,15 @@ public class Estado implements Serializable {
)
@Column(name = "id")
private Integer id;
-
- @Field(store = Store.YES)
- @Field(name = "estadoEs_beginEnd", store = Store.YES, analyzer = @Analyzer(definition = "es_beginEnd"))
+
+ @FullTextField(analyzer = "es_beginEnd")
@NotNull
@NotBlank
@Column(name = "nombre", nullable = false)
private String nombre;
- @Field(termVector = TermVector.YES)
+ @FullTextField(termVector = TermVector.YES)
@NotNull
@NotBlank
@Column(name = "inegi_clave", nullable = false)
diff --git a/src/main/java/com/perales/sepomex/model/InegiClaveCiudad.java b/src/main/java/com/perales/sepomex/model/InegiClaveCiudad.java
index 8aec898..e0b76ad 100644
--- a/src/main/java/com/perales/sepomex/model/InegiClaveCiudad.java
+++ b/src/main/java/com/perales/sepomex/model/InegiClaveCiudad.java
@@ -1,14 +1,15 @@
package com.perales.sepomex.model;
import com.fasterxml.jackson.annotation.*;
+import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.TermVector;
+import org.hibernate.search.engine.backend.types.TermVector;
+import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
+import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
+
-import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@@ -36,7 +37,7 @@ public class InegiClaveCiudad implements Serializable {
@Column(name = "id")
private Integer id;
- @Field(termVector = TermVector.YES)
+ @FullTextField(termVector = TermVector.YES)
@NotNull
@NotBlank
@Column(name = "nombre", nullable = false)
diff --git a/src/main/java/com/perales/sepomex/model/InegiClaveMunicipio.java b/src/main/java/com/perales/sepomex/model/InegiClaveMunicipio.java
index f5c0442..ff6e234 100644
--- a/src/main/java/com/perales/sepomex/model/InegiClaveMunicipio.java
+++ b/src/main/java/com/perales/sepomex/model/InegiClaveMunicipio.java
@@ -1,14 +1,15 @@
package com.perales.sepomex.model;
import com.fasterxml.jackson.annotation.*;
+import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.TermVector;
+import org.hibernate.search.engine.backend.types.TermVector;
+import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
+import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
+
-import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@@ -36,7 +37,7 @@ public class InegiClaveMunicipio implements Serializable {
@Column(name = "id")
private Integer id;
- @Field(termVector = TermVector.YES)
+ @FullTextField(termVector = TermVector.YES)
@NotNull
@NotBlank
@Column(name = "nombre", nullable = false)
diff --git a/src/main/java/com/perales/sepomex/model/Municipio.java b/src/main/java/com/perales/sepomex/model/Municipio.java
index 0cfa30c..4f00e8e 100644
--- a/src/main/java/com/perales/sepomex/model/Municipio.java
+++ b/src/main/java/com/perales/sepomex/model/Municipio.java
@@ -3,16 +3,15 @@
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
+import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
-import org.hibernate.search.annotations.Analyzer;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.Store;
+import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
+import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
+
-import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@@ -40,10 +39,9 @@ public class Municipio implements Serializable {
)
@Column(name = "id")
private Integer id;
-
- @Field(store = Store.YES)
- @Field(name = "municipioEs_beginEnd", store = Store.YES, analyzer = @Analyzer(definition = "es_beginEnd"))
+
+ @FullTextField(analyzer = "es_beginEnd")
@NotNull
@NotBlank
@Column(name = "nombre", nullable = false)
diff --git a/src/main/java/com/perales/sepomex/model/ZonaTipo.java b/src/main/java/com/perales/sepomex/model/ZonaTipo.java
index 5d03f42..692a69d 100644
--- a/src/main/java/com/perales/sepomex/model/ZonaTipo.java
+++ b/src/main/java/com/perales/sepomex/model/ZonaTipo.java
@@ -3,13 +3,14 @@
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
+import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
-import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
+import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
+
-import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
diff --git a/src/main/java/com/perales/sepomex/service/ArchivoService.java b/src/main/java/com/perales/sepomex/service/ArchivoService.java
index 62dccd8..831bb20 100644
--- a/src/main/java/com/perales/sepomex/service/ArchivoService.java
+++ b/src/main/java/com/perales/sepomex/service/ArchivoService.java
@@ -5,17 +5,13 @@
import com.perales.sepomex.model.Archivo;
import com.perales.sepomex.repository.ArchivoRepository;
import org.apache.lucene.search.Query;
-import org.hibernate.search.jpa.FullTextEntityManager;
-import org.hibernate.search.jpa.Search;
-import org.hibernate.search.query.dsl.QueryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
+import jakarta.persistence.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
diff --git a/src/main/java/com/perales/sepomex/service/AsentamientoTipoService.java b/src/main/java/com/perales/sepomex/service/AsentamientoTipoService.java
index 7f53f5d..2773396 100644
--- a/src/main/java/com/perales/sepomex/service/AsentamientoTipoService.java
+++ b/src/main/java/com/perales/sepomex/service/AsentamientoTipoService.java
@@ -4,17 +4,13 @@
import com.perales.sepomex.model.AsentamientoTipo;
import com.perales.sepomex.repository.AsentamientoTipoRepository;
import org.apache.lucene.search.Query;
-import org.hibernate.search.jpa.FullTextEntityManager;
-import org.hibernate.search.jpa.Search;
-import org.hibernate.search.query.dsl.QueryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
+import jakarta.persistence.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -60,30 +56,4 @@ public AsentamientoTipo borrar(Integer id) {
public AsentamientoTipo findBySepomexClave(String sepomexClave) {
return asentamientoTipoRepository.findFirstBySepomexClave(sepomexClave);
}
-
- public List searchByName(String nombre){
- FullTextEntityManager fullTextEntityManager
- = Search.getFullTextEntityManager( em );
- QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory()
- .buildQueryBuilder()
- .forEntity(AsentamientoTipo.class)
- .get();
-
- Query fuzzyQuery = queryBuilder
- .keyword()
- .fuzzy()
- .onField("nombre")
- .matching( nombre)
- .createQuery();
-
- org.hibernate.search.jpa.FullTextQuery jpaQuery
- = fullTextEntityManager.createFullTextQuery(fuzzyQuery, AsentamientoTipo.class);
-
- jpaQuery.setMaxResults(100);
- jpaQuery.limitExecutionTimeTo(1l, TimeUnit.SECONDS);
- List lista = jpaQuery.getResultList();
- fullTextEntityManager.close();
- em.close();
- return lista;
- }
}
diff --git a/src/main/java/com/perales/sepomex/service/CiudadService.java b/src/main/java/com/perales/sepomex/service/CiudadService.java
index 9748e5a..0346406 100644
--- a/src/main/java/com/perales/sepomex/service/CiudadService.java
+++ b/src/main/java/com/perales/sepomex/service/CiudadService.java
@@ -4,17 +4,13 @@
import com.perales.sepomex.model.Ciudad;
import com.perales.sepomex.repository.CiudadRepository;
import org.apache.lucene.search.Query;
-import org.hibernate.search.jpa.FullTextEntityManager;
-import org.hibernate.search.jpa.Search;
-import org.hibernate.search.query.dsl.QueryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
+import jakarta.persistence.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -62,31 +58,4 @@ public Ciudad borrar(Integer id) {
public Ciudad findFirstByNombreAndEstadoId(String nombre, Integer estadoId) {
return ciudadRepository.findFirstByNombreAndEstadoId(nombre, estadoId);
}
-
- @Transactional(readOnly = true)
- public List searchByName(String nombre){
- FullTextEntityManager fullTextEntityManager
- = Search.getFullTextEntityManager( em );
- QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory()
- .buildQueryBuilder()
- .forEntity(Ciudad.class)
- .get();
-
- Query fuzzyQuery = queryBuilder
- .keyword()
- .fuzzy()
- .onField("nombre")
- .matching( nombre)
- .createQuery();
-
- org.hibernate.search.jpa.FullTextQuery jpaQuery
- = fullTextEntityManager.createFullTextQuery(fuzzyQuery, Ciudad.class);
-
- jpaQuery.setMaxResults(100);
- jpaQuery.limitExecutionTimeTo(1l, TimeUnit.SECONDS);
- List lista = jpaQuery.getResultList();
- fullTextEntityManager.close();
- em.close();
- return lista;
- }
}
diff --git a/src/main/java/com/perales/sepomex/service/CodigoPostalService.java b/src/main/java/com/perales/sepomex/service/CodigoPostalService.java
index c625f5a..32c13e5 100644
--- a/src/main/java/com/perales/sepomex/service/CodigoPostalService.java
+++ b/src/main/java/com/perales/sepomex/service/CodigoPostalService.java
@@ -4,17 +4,13 @@
import com.perales.sepomex.model.CodigoPostal;
import com.perales.sepomex.repository.CodigoPostalRepository;
import org.apache.lucene.search.Query;
-import org.hibernate.search.jpa.FullTextEntityManager;
-import org.hibernate.search.jpa.Search;
-import org.hibernate.search.query.dsl.QueryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
+import jakarta.persistence.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -66,30 +62,4 @@ public CodigoPostal borrar(Long id) {
public CodigoPostal findByNombre(String nombre) {
return codigoPostalRepository.findFirstByNombre(nombre);
}
-
- public List searchByName(String nombre){
- FullTextEntityManager fullTextEntityManager
- = Search.getFullTextEntityManager( em );
- QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory()
- .buildQueryBuilder()
- .forEntity(CodigoPostal.class)
- .get();
-
- Query fuzzyQuery = queryBuilder
- .keyword()
- .fuzzy()
- .onField("nombre")
- .matching( nombre)
- .createQuery();
-
- org.hibernate.search.jpa.FullTextQuery jpaQuery
- = fullTextEntityManager.createFullTextQuery(fuzzyQuery, CodigoPostal.class);
-
- jpaQuery.setMaxResults(100);
- jpaQuery.limitExecutionTimeTo(1l, TimeUnit.SECONDS);
- List lista = jpaQuery.getResultList();
- fullTextEntityManager.close();
- em.close();
- return lista;
- }
}
\ No newline at end of file
diff --git a/src/main/java/com/perales/sepomex/service/ColoniaService.java b/src/main/java/com/perales/sepomex/service/ColoniaService.java
index 80e5bcb..0877663 100644
--- a/src/main/java/com/perales/sepomex/service/ColoniaService.java
+++ b/src/main/java/com/perales/sepomex/service/ColoniaService.java
@@ -5,14 +5,10 @@
import com.perales.sepomex.model.*;
import com.perales.sepomex.repository.*;
import com.perales.sepomex.util.Parser;
+import jakarta.persistence.criteria.*;
import lombok.extern.log4j.Log4j2;
-import org.hibernate.Criteria;
-import org.hibernate.FetchMode;
-import org.hibernate.Session;
-import org.hibernate.criterion.Projections;
-import org.hibernate.criterion.Restrictions;
import org.hibernate.search.engine.search.query.SearchQuery;
-import org.hibernate.search.jpa.FullTextEntityManager;
+
import org.hibernate.search.mapper.orm.Search;
import org.hibernate.search.mapper.orm.session.SearchSession;
import org.springframework.beans.factory.annotation.Autowired;
@@ -22,14 +18,7 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.PersistenceContext;
-import javax.persistence.PersistenceUnit;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.JoinType;
-import javax.persistence.criteria.Root;
+import jakarta.persistence.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -412,45 +401,32 @@ public List search(Colonia colonia){
.where( f -> f.match()
.fields( "nombre" )
.matching( colonia.getNombre() ));
- javax.persistence.TypedQuery jpaQuery = Search.toJpaQuery( searchQuery );
+ jakarta.persistence.TypedQuery jpaQuery = Search.toJpaQuery( searchQuery );
org.hibernate.query.Query ormQuery = Search.toOrmQuery( searchQuery );
return null;
}
-
- @SuppressWarnings("deprecated")
- private Criteria createCriteriaSearch(Colonia colonia){
- Session session = (Session) em.getDelegate();
- session.setDefaultReadOnly(true);
- Criteria criteria = session.createCriteria(Colonia.class);
- criteria.setFetchMode("estado", FetchMode.JOIN);
- criteria.setFetchMode("municipio", FetchMode.JOIN);
- criteria.setFetchMode("codigoPostal", FetchMode.JOIN);
-
- if(colonia.getEstado() != null ){
- criteria.add( Restrictions.eq( "estado.id", colonia.getEstado().getId() ) );
- }
- if(colonia.getMunicipio() != null ){
- criteria.add( Restrictions.eq( "municipio.id", colonia.getMunicipio().getId() ) );
- }
+ private CriteriaQuery createCriteriaSearch(Colonia colonia) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery(Colonia.class);
+ Root root = cq.from(Colonia.class);
- Root rootColonia = cq.from(Colonia.class);
- rootColonia.join("estado", JoinType.LEFT);
- rootColonia.join("municipio", JoinType.LEFT);
- rootColonia.join("codigoPostal", JoinType.LEFT);
+ // Joins for associations
+ Join estadoJoin = root.join("estado", JoinType.LEFT);
+ Join municipioJoin = root.join("municipio", JoinType.LEFT);
+ Join codigoPostalJoin = root.join("codigoPostal", JoinType.LEFT);
- cq.select(rootColonia).where();
+ // Filters for search criteria
+ List predicates = new ArrayList<>();
+ if (colonia.getEstado() != null) {
+ predicates.add(cb.equal(estadoJoin.get("id"), colonia.getEstado().getId()));
+ }
+ if (colonia.getMunicipio() != null) {
+ predicates.add(cb.equal(municipioJoin.get("id"), colonia.getMunicipio().getId()));
+ }
+ cq.where(predicates.toArray(new Predicate[0]));
- return criteria;
- }
-
- public int createCriteriaSearchCount(Colonia colonia){
- Criteria criteria = createCriteriaSearch(colonia);
- criteria.setProjection(Projections.rowCount());
- Long count = (Long)criteria.uniqueResult();
- return count.intValue();
+ return cq;
}
// Método para buscar estados y municipios pre-cargados
diff --git a/src/main/java/com/perales/sepomex/service/EstadoService.java b/src/main/java/com/perales/sepomex/service/EstadoService.java
index 18db123..1c19d42 100644
--- a/src/main/java/com/perales/sepomex/service/EstadoService.java
+++ b/src/main/java/com/perales/sepomex/service/EstadoService.java
@@ -4,17 +4,13 @@
import com.perales.sepomex.model.Estado;
import com.perales.sepomex.repository.EstadoRepository;
import org.apache.lucene.search.Query;
-import org.hibernate.search.jpa.FullTextEntityManager;
-import org.hibernate.search.jpa.Search;
-import org.hibernate.search.query.dsl.QueryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
+import jakarta.persistence.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -63,30 +59,5 @@ public Estado borrar(Integer id) {
public Estado findByInegiClave(String inegiClave) {
return estadoRepository.findFirstByInegiClave(inegiClave);
}
-
- public List searchByName(String nombre){
- FullTextEntityManager fullTextEntityManager
- = Search.getFullTextEntityManager( em );
- QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory()
- .buildQueryBuilder()
- .forEntity(Estado.class)
- .get();
-
- Query fuzzyQuery = queryBuilder
- .keyword()
- .fuzzy()
- .onField("nombre")
- .matching( nombre)
- .createQuery();
-
- org.hibernate.search.jpa.FullTextQuery jpaQuery
- = fullTextEntityManager.createFullTextQuery(fuzzyQuery, Estado.class);
-
- jpaQuery.setMaxResults(100);
- jpaQuery.limitExecutionTimeTo(1l, TimeUnit.SECONDS);
- List lista = jpaQuery.getResultList();
- fullTextEntityManager.close();
- em.close();
- return lista;
- }
+
}
diff --git a/src/main/java/com/perales/sepomex/service/InegiClaveCiudadService.java b/src/main/java/com/perales/sepomex/service/InegiClaveCiudadService.java
index f19c248..5f64507 100644
--- a/src/main/java/com/perales/sepomex/service/InegiClaveCiudadService.java
+++ b/src/main/java/com/perales/sepomex/service/InegiClaveCiudadService.java
@@ -4,17 +4,13 @@
import com.perales.sepomex.model.InegiClaveCiudad;
import com.perales.sepomex.repository.InegiClaveCiudadRepository;
import org.apache.lucene.search.Query;
-import org.hibernate.search.jpa.FullTextEntityManager;
-import org.hibernate.search.jpa.Search;
-import org.hibernate.search.query.dsl.QueryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
+import jakarta.persistence.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -60,30 +56,4 @@ public InegiClaveCiudad borrar(Integer id) {
public InegiClaveCiudad findFirstByNombre(String nombre) {
return inegiClaveCiudadRepository.findFirstByNombre(nombre);
}
-
- public List searchByName(String nombre){
- FullTextEntityManager fullTextEntityManager
- = Search.getFullTextEntityManager( em );
- QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory()
- .buildQueryBuilder()
- .forEntity(InegiClaveCiudad.class)
- .get();
-
- Query fuzzyQuery = queryBuilder
- .keyword()
- .fuzzy()
- .onField("nombre")
- .matching( nombre)
- .createQuery();
-
- org.hibernate.search.jpa.FullTextQuery jpaQuery
- = fullTextEntityManager.createFullTextQuery(fuzzyQuery, InegiClaveCiudad.class);
-
- jpaQuery.setMaxResults(100);
- jpaQuery.limitExecutionTimeTo(1l, TimeUnit.SECONDS);
- List lista = jpaQuery.getResultList();
- fullTextEntityManager.close();
- em.close();
- return lista;
- }
}
diff --git a/src/main/java/com/perales/sepomex/service/InegiClaveMunicipioService.java b/src/main/java/com/perales/sepomex/service/InegiClaveMunicipioService.java
index a3fba61..48cf38d 100644
--- a/src/main/java/com/perales/sepomex/service/InegiClaveMunicipioService.java
+++ b/src/main/java/com/perales/sepomex/service/InegiClaveMunicipioService.java
@@ -4,17 +4,13 @@
import com.perales.sepomex.model.InegiClaveMunicipio;
import com.perales.sepomex.repository.InegiClaveMunicipioRepository;
import org.apache.lucene.search.Query;
-import org.hibernate.search.jpa.FullTextEntityManager;
-import org.hibernate.search.jpa.Search;
-import org.hibernate.search.query.dsl.QueryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
+import jakarta.persistence.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -60,30 +56,4 @@ public InegiClaveMunicipio borrar(Integer id) {
public InegiClaveMunicipio findFirstByNombre(String nombre) {
return inegiClaveMunicipioRepository.findFirstByNombre(nombre);
}
-
- public List searchByName(String nombre){
- FullTextEntityManager fullTextEntityManager
- = Search.getFullTextEntityManager( em );
- QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory()
- .buildQueryBuilder()
- .forEntity(InegiClaveMunicipio.class)
- .get();
-
- Query fuzzyQuery = queryBuilder
- .keyword()
- .fuzzy()
- .onField("nombre")
- .matching( nombre)
- .createQuery();
-
- org.hibernate.search.jpa.FullTextQuery jpaQuery
- = fullTextEntityManager.createFullTextQuery(fuzzyQuery, InegiClaveMunicipio.class);
-
- jpaQuery.setMaxResults(100);
- jpaQuery.limitExecutionTimeTo(1l, TimeUnit.SECONDS);
- List lista = jpaQuery.getResultList();
- fullTextEntityManager.close();
- em.close();
- return lista;
- }
}
diff --git a/src/main/java/com/perales/sepomex/service/MunicipioService.java b/src/main/java/com/perales/sepomex/service/MunicipioService.java
index 2a26609..0be21b4 100644
--- a/src/main/java/com/perales/sepomex/service/MunicipioService.java
+++ b/src/main/java/com/perales/sepomex/service/MunicipioService.java
@@ -4,17 +4,13 @@
import com.perales.sepomex.model.Municipio;
import com.perales.sepomex.repository.MunicipioRepository;
import org.apache.lucene.search.Query;
-import org.hibernate.search.jpa.FullTextEntityManager;
-import org.hibernate.search.jpa.Search;
-import org.hibernate.search.query.dsl.QueryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
+import jakarta.persistence.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -67,30 +63,4 @@ public Page findByEstadoId(Integer estadoId, int page, int size){
int firstResult = page * size;
return municipioRepository.findByEstadoIdOrderByNombre(estadoId, PageRequest.of(firstResult, size ));
}
-
- public List searchByName(String nombre){
- FullTextEntityManager fullTextEntityManager
- = Search.getFullTextEntityManager( em );
- QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory()
- .buildQueryBuilder()
- .forEntity(Municipio.class)
- .get();
-
- Query fuzzyQuery = queryBuilder
- .keyword()
- .fuzzy()
- .onField("nombre")
- .matching( nombre)
- .createQuery();
-
- org.hibernate.search.jpa.FullTextQuery jpaQuery
- = fullTextEntityManager.createFullTextQuery(fuzzyQuery, Municipio.class);
-
- jpaQuery.setMaxResults(100);
- jpaQuery.limitExecutionTimeTo(1l, TimeUnit.SECONDS);
- List lista = jpaQuery.getResultList();
- fullTextEntityManager.close();
- em.close();
- return lista;
- }
}
diff --git a/src/main/java/com/perales/sepomex/service/ZonaTipoService.java b/src/main/java/com/perales/sepomex/service/ZonaTipoService.java
index e55fe75..cf0c627 100644
--- a/src/main/java/com/perales/sepomex/service/ZonaTipoService.java
+++ b/src/main/java/com/perales/sepomex/service/ZonaTipoService.java
@@ -4,17 +4,13 @@
import com.perales.sepomex.model.ZonaTipo;
import com.perales.sepomex.repository.ZonaTipoRepository;
import org.apache.lucene.search.Query;
-import org.hibernate.search.jpa.FullTextEntityManager;
-import org.hibernate.search.jpa.Search;
-import org.hibernate.search.query.dsl.QueryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
+import jakarta.persistence.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -60,30 +56,4 @@ public ZonaTipo borrar(Integer id) {
public ZonaTipo findByNombre(String nombre) {
return zonaTipoRepository.findFirstByNombre(nombre);
}
-
- public List searchByName(String nombre){
- FullTextEntityManager fullTextEntityManager
- = Search.getFullTextEntityManager( em );
- QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory()
- .buildQueryBuilder()
- .forEntity(ZonaTipo.class)
- .get();
-
- Query fuzzyQuery = queryBuilder
- .keyword()
- .fuzzy()
- .onField("nombre")
- .matching( nombre)
- .createQuery();
-
- org.hibernate.search.jpa.FullTextQuery jpaQuery
- = fullTextEntityManager.createFullTextQuery(fuzzyQuery, ZonaTipo.class);
-
- jpaQuery.setMaxResults(100);
- jpaQuery.limitExecutionTimeTo(1l, TimeUnit.SECONDS);
- List lista = jpaQuery.getResultList();
- fullTextEntityManager.close();
- em.close();
- return lista;
- }
}
diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties
index 9d604b0..0564019 100644
--- a/src/main/resources/application-local.properties
+++ b/src/main/resources/application-local.properties
@@ -6,17 +6,19 @@ spring.servlet.multipart.max-file-size=20MB
spring.servlet.multipart.max-request-size=20MB
spring.http.multipart.enabled=true
-spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQL95Dialect
+spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.jpa.properties.hibernate.hbm2ddl.auto=update
spring.jpa.properties.hibernate.jdbc.batch_size=50000
spring.jpa.properties.hibernate.order_inserts=false
spring.jpa.properties.hibernate.order_updates= false
spring.jpa.properties.hibernate.show_sql=true
-spring.jpa.properties.hibernate.search.default.directory_provider=filesystem
-spring.jpa.properties.hibernate.search.default.indexBase=sepomex-indices/
spring.datasource.hikari.maximum-pool-size=120
spring.datasource.hikari.minimum-idle=80
+spring.jpa.properties.hibernate.search.backend.indexing.queue_size = 1000
+spring.jpa.properties.hibernate.search.backend.indexing.queue_size_autocommit = 100
+spring.jpa.properties.hibernate.search.backend.indexing.thread_pool.size = 10
+spring.jpa.properties.hibernate.search.backend.analysis.configurer = com.perales.sepomex.util.MyLuceneAnalysisConfigurer
spring.datasource.url=jdbc:postgresql://localhost:5432/sepomex
spring.datasource.username=sepomex
diff --git a/src/test/java/com/perales/sepomex/configuration/AppTestConfig.java b/src/test/java/com/perales/sepomex/configuration/AppTestConfig.java
index 38a4994..05c707d 100644
--- a/src/test/java/com/perales/sepomex/configuration/AppTestConfig.java
+++ b/src/test/java/com/perales/sepomex/configuration/AppTestConfig.java
@@ -11,7 +11,7 @@
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
-import javax.persistence.EntityManagerFactory;
+import jakarta.persistence.*;
import javax.sql.DataSource;
import java.util.Properties;
diff --git a/src/test/java/com/perales/sepomex/controller/ColoniaControllerTest.java b/src/test/java/com/perales/sepomex/controller/ColoniaControllerTest.java
index 6a1a7cb..17f1f75 100644
--- a/src/test/java/com/perales/sepomex/controller/ColoniaControllerTest.java
+++ b/src/test/java/com/perales/sepomex/controller/ColoniaControllerTest.java
@@ -16,6 +16,8 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
+import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
@@ -23,7 +25,8 @@
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.is;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.fileUpload;
+import org.springframework.mock.web.MockMultipartFile;
+import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
@SpringBootTest(classes = AppTestConfig.class)
@@ -139,16 +142,18 @@ public void borrar() throws Exception {
@Test
public void cargaMasiva() throws Exception {
- MockMultipartFile multipartFile = new MockMultipartFile("file", "test.txt",
- "text/plain", sepomexText.getBytes());
-
- StringBuilder sb = new StringBuilder(API_URL);
- sb.append("carga");
- ResultActions response = mockMvc.perform(fileUpload(sb.toString())
- .file(multipartFile));
+ MockMultipartFile multipartFile = new MockMultipartFile(
+ "file", // nombre del parámetro del archivo
+ "test.txt", // nombre del archivo original
+ MediaType.TEXT_PLAIN_VALUE, // tipo de contenido
+ sepomexText.getBytes() // contenido del archivo
+ );
- logger.info( response.andReturn().getResponse().getContentAsString() );
- response.andExpect( status().is2xxSuccessful() );
+ String endpoint = API_URL + "carga";
+ mockMvc.perform(MockMvcRequestBuilders.multipart(endpoint)
+ .file(multipartFile))
+ .andDo(MockMvcResultHandlers.print()) // para imprimir la respuesta en el log
+ .andExpect(MockMvcResultMatchers.status().is2xxSuccessful());
}
@Test