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

jdbc Article's
30 articles in total
Favicon
Simplify Python-Informix Connections with wbjdbc
Favicon
🚀 Mastering JDBC: Bridging Java and Databases Seamlessly 📊
Favicon
LIBRARY MANAGEMENT SYSTEM USING JAVA AND SQL
Favicon
Java JDBC + IntelliJ + SQLite - A Beginner's Walkthrough
Favicon
Java Backend Management Project
Favicon
JDBC and Streams have never been simpler
Favicon
Quick tip: Using SingleStore for Iceberg Catalog Storage
Favicon
Introducing Kuery Client for those who love writing SQL in Kotlin/JVM
Favicon
Performance tests IRIS - PostgreSQL - MySQL
Favicon
Mastering Conversations: A Guide to Building and Using a Java-Based Chat (StarChat) with IRIS Cloud SQL.
Favicon
Understanding JDBC Three-Tier Architecture: A Detailed Overview
Favicon
Spring Boot Security with JDBC Authentication
Favicon
Wednesday Links - Edition 2024-01-10
Favicon
Constant Lag in CDC Pipeline (JDBC Sink Connector)
Favicon
How to Connect Java Applications to Databases with JDBC
Favicon
Wednesday Links - Edition 2023-08-30
Favicon
How JDBC Paved the Way for Java Frameworks! 🛤️
Favicon
Connect to JDBC in java using MySQL
Favicon
JDBC program for Delete operation
Favicon
Spring JDBC 6 CRUD Operations
Favicon
Java JDBC CRUD Operations in Eclipse using MySql
Favicon
Tutorial - Develop IRIS using SSH
Favicon
Spark Update Optimizations
Favicon
Tips and tricks of the brand new LOAD DATA command
Favicon
Configure the SQuirreL SQL Client to use the SingleStore JDBC Driver
Favicon
Mapping with SCHEMA
Favicon
Built in multi model integration using InterSystems iris data platform
Favicon
Use JDBC to connect TiDB Cloud through TLS
Favicon
Connect your Java application with any SQL databases
Favicon
Java and MySQL

Featured ones: