Coder Social home page Coder Social logo

mc10-springboot-mysql's Introduction

mc10-springboot-mysql

Clase Magistral 10 - Argentina Programa - Java Spring Boot

Cronograma de clases oficial:

https://argentinaprograma.inti.gob.ar/mod/page/view.php?id=566

Textos oficiales ArgentinaPrograma Java Spring Boot: https://argentinaprograma.inti.gob.ar/mod/page/view.php?id=515

Masterclass grabada oficial ArgentinaPrograma: https://argentinaprograma.inti.gob.ar/mod/page/view.php?id=559

Un curso de Java Spring boot para ver los contenidos y la cantidad de clases de profesionales que enseñan esto: https://sceu.frba.utn.edu.ar/e-learning/detalle/curso/1270/fundamentos-de-spring-framework-para-java?gclid=CjwKCAiAyPyQBhB6EiwAFUuakj9MDbO2vzNwyXU_j2hRVdBRHaWExSNRlydI2zNANDEy2kDfCf0iuBoCGAoQAvD_BwE

Página oficial Java Spring Boot: https://spring.io/projects/spring-boot

PRECONDICIONES:

Tener instalado / instalar lo siguiente:

Glosario de esta clase:

  • Entidad / Business Object / Objeto de negocios
  • Data Transfer Object (DTO)
  • Data Access Object (DAO) / Repository / spring-data-jpa / mysql-driver / h2-database (solo si quiero mockear una db local)
  • JPA (Java Persistence API)
  • REST API (GET, POST, PUT, DELETE) / Webservices
  • XML (Extensible Markup Language)
  • Apache Tomcat
  • PathVariables
  • Query strings (query params - RequestParam en spring)

Vamos a https://start.spring.io/ y creamos nuestro primer proyecto Spring (spring data jpa, mysql connector, spring web, spring boot DevTools)

MVC (Model View Controller)

Las operaciones HTTP más importantes que nos permitirán manipular los recursos son cuatro:

  • GET para consultar y leer
  • POST para crear
  • PUT para editar
  • DELETE para eliminar.

Other Sources > application properties (poner la configuración de la Base de datos que vamos a usar)

# Hibernate ddl auto (create, create-drop, validate, update, none)
spring.jpa.hibernate.ddl-auto= update

spring.jpa.hibernate.ddl-auto=update

spring.datasource.url=jdbc:mysql://localhost:3306/spring_jpa?useSSL=false&serverTimezone=UTC

spring.datasource.username=root

spring.datasource.password=1234

spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect

javax.persistent.entity

En el PersonaRepository poner:

@Repository

public interface PersonaRepository extends JpaRepository <Persona, Long> {

}

Para inyección de dependencias de los repositories, usamos una inyección de dependencias de Spring

@Autowired

El service necesita el @Service

Controller:

@RestController

@PostMapping

@GetMapping

@PutMapping

@DeleteMapping

etcccc

Controller → Service → Repository

Untitled

Untitled

https://www.youtube.com/watch?v=vTu2HQrXtyw&ab_channel=DATACLOUDER

Screen Shot 2022-03-03 at 18.12.08.png

CLIENTE → Controller → Service → Repository + Model ⇒ BASE DE DATOS

BASE DE DATOS ⇒ Model + Repository → Service → Controller → CLIENTE

Hibernate JPA Spring Annotations

https://thorben-janssen.com/key-jpa-hibernate-annotations/

@Entity

public class MyEntity {

@Id

@GeneratedValue(strategy = GenerationType.IDENTITY)

@ Column(name = "id", updatable = **false**, nullable = **false**)

**private** Long id;

@ManyToOne(fetch = FetchType.LAZY)

**private** Publisher publisher;

@OneToMany(mappedBy = "publisher", cascade = CascadeType.ALL)

@OneToMany(mappedBy = "publisher", cascade = CascadeType.ALL)

**private** Set<Book> books;

@OneToOne(fetch = FetchType.LAZY)

**private** Book book;

@OneToOne(mappedBy = "book")

**private** Manuscript manuscript;

Un tutorial completo con ManyToMany y todo el codigo java / dbs / spring etc!

https://www.bezkoder.com/jpa-many-to-many/

Accessing JPA Data with REST (springboot)

https://spring.io/guides/gs/accessing-data-rest/

[https://tutorialmeta.com/question/spring-data-jpa-manytomany-delete-entities-of-the-join-table](Otro ejemplo ManyToMany con sugerencias)

Clase

mc10-springboot-mysql's People

Contributors

hernanborre avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.