Skip to content

Commit

Permalink
* Codigo compila pero spring boot aun no es compatible con hibernate …
Browse files Browse the repository at this point in the history
…search
  • Loading branch information
ripper2hl committed Apr 8, 2024
1 parent ad8e5bc commit 7b6d3f8
Show file tree
Hide file tree
Showing 33 changed files with 121 additions and 491 deletions.
77 changes: 5 additions & 72 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
<javax.el.api.version>3.0.1-b06</javax.el.api.version>
<javax.el.version>3.0.1-b12</javax.el.version>
<jaxb.api.version>2.4.0-b180830.0359</jaxb.api.version>
<hibernate.search.orm.version>6.0.10.Final</hibernate.search.orm.version>
<hibernate.search.orm.version>6.2.3.Final</hibernate.search.orm.version>
<hamcrest.all.version>1.3</hamcrest.all.version>
<postgresql.version>42.4.2</postgresql.version>
<postgresql.version>42.7.3</postgresql.version>
<jakarta.validation.api>2.0.2</jakarta.validation.api>
<springdoc.openapi.ui>1.7.0</springdoc.openapi.ui>
</properties>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.18</version>
<version>3.2.4</version>
</parent>

<dependencies>
Expand Down Expand Up @@ -115,19 +115,14 @@

<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-mapper-orm</artifactId>
<artifactId>hibernate-search-mapper-orm-orm6</artifactId>
<version>${hibernate.search.orm.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-backend-lucene</artifactId>
<version>${hibernate.search.orm.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-v5migrationhelper-orm</artifactId>
<version>${hibernate.search.orm.version}</version>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
Expand Down Expand Up @@ -174,7 +169,7 @@

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate5</artifactId>
<artifactId>jackson-datatype-hibernate6</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -259,67 +254,5 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>gcp</id>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>1.2.7.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-indexer</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-sql-postgresql</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<deploy.projectId>sepomex-api</deploy.projectId>
<deploy.version>3</deploy.version>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>application.properties</exclude>
</excludes>
</resource>
</resources>
</build>
</profile>
</profiles>
</project>
4 changes: 2 additions & 2 deletions src/main/java/com/perales/sepomex/Application.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<AsentamientoTipo> searchByName(@PathVariable String name) {
return asentamientoTipoService.searchByName(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ciudad> searchByName(@PathVariable String name) {
return ciudadService.searchByName(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<CodigoPostal> searchByName(@PathVariable String name) {
return codigoPostalService.searchByName(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Estado> searchByName(@PathVariable String name) {
return estadoService.searchByName(name);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<InegiClaveCiudad> searchByName(@PathVariable String name) {
return inegiClaveCiudadService.searchByName(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<InegiClaveMunicipio> searchByName(@PathVariable String name) {
return inegiClaveMunicipioService.searchByName(name);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,4 @@ public Municipio borrar( @PathVariable Integer id) {
public Page<Municipio> findByEstadoId( @PathVariable Integer id, @RequestParam int page, @RequestParam int size) {
return municipioService.findByEstadoId(id, page, size);
}

@GetMapping(value = "/name/{name}")
public List<Municipio> searchByName(@PathVariable String name) {
return municipioService.searchByName(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ZonaTipo> searchByName(@PathVariable String name) {
return zonaTipoService.searchByName(name);
}
}
6 changes: 1 addition & 5 deletions src/main/java/com/perales/sepomex/model/Archivo.java
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
35 changes: 15 additions & 20 deletions src/main/java/com/perales/sepomex/model/AsentamientoTipo.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,49 @@
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;
import java.util.List;

@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<Colonia> colonias;
}
17 changes: 9 additions & 8 deletions src/main/java/com/perales/sepomex/model/Ciudad.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
12 changes: 7 additions & 5 deletions src/main/java/com/perales/sepomex/model/CodigoPostal.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/perales/sepomex/model/Colonia.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +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 lombok.ToString;
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;
Expand Down
Loading

0 comments on commit 7b6d3f8

Please sign in to comment.