Logo

dev-resources.site

for different kinds of informations.

Mapping with SCHEMA

Published at
10/15/2022
Categories
oracle
micronaut
jdbc
Author
e240683
Categories
3 categories in total
oracle
open
micronaut
open
jdbc
open
Author
7 person written this
e240683
open
Mapping with SCHEMA

Una mala pr谩ctica en la configuraci贸n de aplicaciones, es usar el owner del esquema para acceder a la base de datos.
Es recomendable crear una cuenta de usuario y otorgar los permisos necesarios y espec铆ficos.

Pongamos como ejemplo:

  • ESQUEMA: REGIONALIZACION
  • USUARIO: MSPRODUCTOSWOW
  • PERMISOS:
-- Oracle
GRANT SELECT, INSERT, UPDATE 
ON REGIONALIZACION.LGT_PROD_LOCAL_OFERTA_AUX 
TO MSPRODUCTOSWOW
Enter fullscreen mode Exit fullscreen mode

Empleando las anotaciones de Jakarta Persistence, definimos el mapping de nuestra Entity: name/schema.

import jakarta.persistence.*;

@Table(name = "LGT_PROD_LOCAL_OFERTA_AUX", schema = "REGIONALIZACION")
public record WOWProduct(@EmbeddedId WOWProductId id,
                         float porcDctoOferta,
                         LocalDateTime fecIniVigOferta,
                         LocalDateTime fecFinVigOferta,
                         String usuCreaProdLocOfe,
                         LocalDateTime fecCreaProdLocOfe) {
}
Enter fullscreen mode Exit fullscreen mode

N贸tese que podemos usar record, incluso para definir una llave compuesta.

@Embeddable
record WOWProductId(
        @Column(name = "COD_GRUPO_CIA") String codGrupoCia,
        @Column(name = "COD_LOCAL") String codLocal,
        @Column(name = "COD_OFERTA") String codOferta,
        @Column(name = "COD_PROD") String codProd) {
}
Enter fullscreen mode Exit fullscreen mode

Ejecutamos nuestro proyecto basado en #Micronaut:
Image description

Y al listar los productos:
Image description


Documentaci贸n

https://micronaut-projects.github.io/micronaut-data/latest/guide/#sqlAnnotations
https://github.com/edgargs/mn-jdbc-schema

micronaut Article's
30 articles in total
Favicon
Pub-sub Redis in Micronaut
Favicon
Choosing the Right Java Microservices Framework: Spring Boot, Quarkus, Micronaut, and Beyond
Favicon
Micronaut vs. Spring Boot: A Detailed Comparison
Favicon
[Micronaut] Receiving Japanese(Shift-JIS) data as HTTPResponse
Favicon
[Micronaut] Try Cookie
Favicon
[Micronaut] Generating and downloading files as ZIP or JSON
Favicon
Sending files from Micronaut applications
Favicon
[Micronaut] Receiving multipart/form-data
Favicon
Try Micronaut and Doma2
Favicon
[Micronaut] Accessing SQL Server 2
Favicon
Serving static assets with Micronaut
Favicon
Run a Micronaut application on Tomcat
Favicon
[Micronaut] Accessing SQL Server 3
Favicon
[Micronaut] Accessing SQL Server 1
Favicon
Try Micronaut
Favicon
Adding AI to your Micronaut search service
Favicon
Swagger-Operator, let groovy operate your cluster
Favicon
Jugando con Mono y Flux (de Reactor)
Favicon
Meeting & Mastering Java
Favicon
Integration testing in Micronaut
Favicon
mapping OpenAPI formats
Favicon
Connecting Micronaut to MongoDB database using Kotlin
Favicon
馃 Micronaut: Top 5 Server-Side Frameworks for Kotlin in 2022
Favicon
AWS Lambda SnapStart - Part 2 Measuring Java 11 Lambda cold starts with Micronaut framework
Favicon
Integration Tests with Micronaut and Kotlin
Favicon
Mapping with SCHEMA
Favicon
annotation mapping & bean-validation
Favicon
Can Micronaut replace Spring Boot? Let's take a look at an example.
Favicon
Cloud Native Java: Integrating YugabyteDB with Spring Boot, Quarkus, and Micronaut
Favicon
Micronaut Pulsar

Featured ones: