Ausnahme gefangen: SSL certificate problem: certificate is not yet valid 📌 Full Stack Development with Spring Boot and React (အခန်သ ၂)

🏠 Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, BlogbeitrÀge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden Überblick ÃŒber die wichtigsten Aspekte der IT-Sicherheit in einer sich stÀndig verÀndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch Ìbersetzen, erst Englisch auswÀhlen dann wieder Deutsch!

Google Android Playstore Download Button fÃŒr Team IT Security



📚 Full Stack Development with Spring Boot and React (အခန်သ ၂)


💡 Newskategorie: Programmierung
🔗 Quelle: dev.to

JPA
JPA ဆိုတာ standard တစ်ခုဖဌစ်ပါတယ်။ JPA ကို အခဌေခံပဌီသ Hibernate, Eclipse-Link အစရဟိသဖဌင့် implementation လုပ်ကဌပါတယ်။ အဲဒီထဲမဟာ အသုံသအမျာသဆုံသက Hibernate
implementation ဖဌစ်ပါတယ်။ ဥပမာ HTML language ဆိုတာ standard ဖဌစ်ပဌီသ သူ့ကို render လုပ်တဲ့ browser implementation တလေမတူကဌသလိုပါပဲ။
ဥပမာ Firefox, Chrome, Edge အစရဟိသဖဌင့်ပေါ့။ JPA ကိုပဌန်ပဌောရမယ်ဆိုရင်တော့ JPA entity ဆိုတာ database table ကို ကိုယ်စာသပဌုတဲ့ Java class ဖဌစ်ပါတယ်။
အဲဒီ class ရဲ့ field တလေကတော့ database table ရဲ့ column တလေကို ကိုယ်စာသပဌုပါတယ်။ ပဌီသရင် example နဲ့တကလပဌပါ့မယ်။

Hibernate
Hibernate ဟာ JPA implementation တလေထဲမဟာ ပေါ်ပဌူလာအဖဌစ်ဆုံသ ဖဌစ်ပဌီသ Spring Boot က သူ့ကို default အနေနဲ့ ထည့်ထာသပေသပါတယ်။ Hibernate ဟာ mature ဖဌစ်နေပဌီ
ဖဌစ်တဲ့အပဌင် large-scale application ကဌီသတလေမဟာ ကို သုံသကဌပါတယ်။

Entity class မျာသ create လုပ်ခဌင်သ
Entity class class ဆိုတာ JPA ရဲ့ @Entity ဆိုတဲ့ annotation ကို class definition မဟာရေသထာသတဲ့ class ကိုခေါ်ပါတယ်။
Entity class မဟာ getter နဲ့ setter method တလေပါရမဟာဖဌစ်ပဌီသ။ သူ့ရဲ့ field တလေကိုတော့ private ကဌေငဌာထာသရပါမယ်။

Application ကို စ run လိုက်တာနဲ့ JPA ဟာ database မဟာ table တလေ သလာသဆောက်ပါတယ်။ @Entity နဲ့ ရေသထာသတဲ့ class တလေ အကုန်လုံသ
database table အဖဌစ်နဲ့ database ထဲ အလိုအလျောက်သလာသဆောက်မဟာဖဌစ်ပါတယ်။

ဥပမာ Entity class name က Car ဆိုရင် Car ဆိုတဲ့
table ကို အလိုလိုသလာသဆောက်မဟာပါ။ တကယ်လို့ ကိုယ်က Car လို့ မဆောက်ချင်ဘူသ။ MotorCar လို့ ဆောက်ချင်တယ်ဆိုရင် @Entity ရဲ့ အောက်မဟာ
@Table ဆိုတဲ့ annotation ကို သုံသပဌီသ table name ကို သီသသန့် set လုပ်လို့ရပါတယ်။

ကဲ အဲဒီတော့ example စကဌည့်ကဌရအောင်။
JPA နဲ့ H2 database နဲ့ သုံသဖို့ ပထမဆုံသ pom.xml ဖိုင်ထဲမဟာ dependencies တလေ ထပ်ထည့်ရအောင်။


<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
   <groupId>com.h2database</groupId>
   <artifactId>h2</artifactId>
   <scope>runtime</scope>
</dependency>

Entity class ကို create လုပ်ပုံအဆင့်ဆင့် ကို ကဌည့်ရအောင်။

Project Explorer မဟာ root package ကို right click နဟိပ်ရင် menu ပေါ်လာပါလိမ့်မယ်။
New ကို ရလေသပဌီသ အဲဒီထဲကမဟ package ကို ရလေသပါ

Image description

package name ကို com.packt.demo.domain လို့ပေသလိုက်ပါ။

အသစ်ဆောက်ထာသတဲ့ package ကို Project Explorer မဟာ right click နဟိပ်ပါ။ ပဌီသရင် New ကိုရလေသပဌီသ class ကိုရလေသလိုက်ပါ။ ဒါဆိုရင် Java class အသစ်တစ်ခုရပဌီ။

Image description

ပဌီသရင် annotation ဖဌစ်တဲ့ @Entity ကို Car class ပေါ်မဟာ သတ်မဟတ်ပေသလိုက်ပါ။
(@Entity ရေသပဌီသ Ctrl+Space ဒါမဟမဟုတ် Ctrl+Shift+O ကို နဟိပ်ရင် import statement အော်တိုထလက်လာပါလိမ့်မယ်။)

package com.packt.demo.domain;
import javax.persistence.Entity;

@Entity
public class Car {

}

ပဌီသရင် field တလေ(database column ဖဌစ်လာမယ့်အရာတလေ) ကို define လုပ်ရအောင်။ ဒီနေရာမဟာ unqiue ID ကိုလည်သ ထည့်ပေသရပါလိမ့်မယ်(primary key အနေနဲ့သုံသရအောင်ပါ)။

package com.packt.demo.domain;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
public class Car {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private long id;
    private String brand, model, color, registerNumber;
    private int yearMade, price;
}

primary key ကို define လုပ်ဖို့ @id
ID ကို database ကနေ Auto generate လုပ်ပေသဖို့ @GeneratedValue
JPA provider(ဒီနေရာမဟာ Hibernate) က အသင့်တော်ဆုံသ ID generation ကို လုပ်ပေသပါလို့ပဌောတာက (strategy=GenerationType.AUTO)

ပဌီသပဌီဆိုရင် field တလေအတလက် getter နဲ့ setter တလေ ထည့်ပေသရမယ်။ field တလေကို တိုက်ရိုက် set လုပ်ပေသနိုင်မယ့် constructor ထည့်ပေသရမယ်။

class ထဲမဟာ cursor ကိုထာသပဌီသ Right Click-> Source -> Generate Getter and Setters
ဆိုရင် getter setter တလေထလက်လာမယ်။

class ထဲမဟာ cursor ကိုထာသပဌီသ Right Click-> Source -> Generate Constructor using fields....
လို့ရလေသ ပဌီသရင် ID ကို ဖဌုတ်(id က auto generate လုပ်မဟာ ဆိုတော့ constructor နဲ့ assign လုပ်ရင် ထည့်မပေသရဘူသ)

package com.packt.demo.domain;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
public class Car {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;
    private String brand, model, color, registerNumber;
    private int yearMade, price;

    public Car() {
    }

    public Car(String brand, String model, String color, String registerNumber, int yearMade, int price) {
        super();
        this.brand = brand;
        this.model = model;
        this.color = color;
        this.registerNumber = registerNumber;
        this.yearMade = yearMade;
        this.price = price;
    }

    public String getBrand() {
            return brand;
        }

        public void setBrand(String brand) {
            this.brand = brand;
        }

        public String getModel() {
            return model;
        }

        public void setModel(String model) {
            this.model = model;
        }

        public String getColor() {
            return color;
        }

        public void setColor(String color) {
            this.color = color;
        }

        public String getRegisterNumber() {
            return registerNumber;
        }

        public void setRegisterNumber(String registerNumber) {
            this.registerNumber = registerNumber;
        }

        public long getId() {
            return id;
        }

        public void setId(long id) {
            this.id = id;
        }

        public int getYearMade() {
            return yearMade;
        }

        public void setYearMade(int yearMade) {
            this.yearMade = yearMade;
        }

        public int getPrice() {
            return price;
        }

        public void setPrice(int price) {
            this.price = price;
        }
}

ပဌီသရင် H2 database နဲ့ချိတ်ဖို့ application.properties ထဲမဟာ အောက်ပါအတိုင်သ configure လုပ်ကဌမယ်။

spring.h2.console.enabled=true
spring.datasource.platform=h2
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:test
spring.h2.console.path=/h2-console
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update

h2 မဟာ webconsole ပါပါတယ်။ database url name က jdbc:h2:mem:test ဆိုတာကိုလည်သ သတိထာသမိမယ်ထင်ပါတယ်။ ကဲ Run As ->Java Application လုပ်လိုက်ပါ။ H2 database ထဲမဟာ ဘာရောက်သလာသလည်သကဌည့်ရအောင်။
အရင်ဆုံသ Spring Boot run ပဌီသရင် http://localhost:8080/h2-console ကို browser မဟာ ဖလင့်ကဌည့်ပါ

Image description

url ကို jdbc:h2:mem:test လို့ပဌောင်သပဌီသ ဝင်လိုက်ပါ။

Image description

JPA က လဟမ်သပဌီသ create လုပ်ပေသလိုက်တဲ့ database table ဖဌစ်တဲ့ Car table ကို တလေ့ရမဟာဖဌစ်ပါတယ်။

=======================
အခန်သ(၂) ပဌီသ

...



📌 Full Stack Development with Spring Boot and React (အခန်သ ၂)


📈 91.15 Punkte

📌 Full Stack React & Spring Boot App Tutorial


📈 42.87 Punkte

📌 software-architektur.tv: GraalVM mit Spring Native, Spring Boot und Spring Cloud


📈 40.13 Punkte

📌 Going Full-Stack With Kotlin/JS and Spring Boot


📈 35.7 Punkte

📌 Full Stack Development with MongoDB, Java, and React


📈 33.15 Punkte

📌 Build CRUD RESTful API Using Spring Boot 3, Spring Data JPA, Hibernate, and MySQL Database


📈 31.38 Punkte

📌 Upgrade Guide To Spring Boot 3.0 for Spring Data JPA and Querydsl


📈 31.38 Punkte

📌 Querydsl vs. JPA Criteria, Part 6: Upgrade Guide To Spring Boot 3.2 for Spring Data JPA and Querydsl Project


📈 31.38 Punkte

📌 Learn Spring Boot and Spring Data JPA


📈 31.38 Punkte

📌 Generative AI With Spring Boot and Spring AI


📈 31.38 Punkte

📌 Why I choose T3 stack as the full-stack to build the react app


📈 30.63 Punkte

📌 Building a Real-Time App With Spring Boot, Cassandra, Pulsar, React, and Hilla


📈 29.79 Punkte

📌 Authentication Service with Spring Boot and React client — Part 2


📈 29.79 Punkte

📌 Authentication Service with Spring Boot and React client


📈 29.79 Punkte

📌 Spring Boot 2.0 mit Support fÃŒr Spring Framework 5.0 veröffentlicht


📈 29.59 Punkte

📌 Spring Tools 4.6.0 versprechen mehr Leistung fÃŒr Spring Boot


📈 29.59 Punkte

📌 Azure Spring Cloud - a fully managed service for Spring Boot apps


📈 29.59 Punkte

📌 Spring Boot 3.0 setzt auf Spring Framework 6.0 und Java 17


📈 29.59 Punkte

📌 Introducing Azure Spring Cloud: fully managed service for Spring Boot microservices


📈 29.59 Punkte

📌 Introducing Azure Spring Cloud: fully managed service for Spring Boot microservices


📈 29.59 Punkte

📌 Spring Boot & Spring Data JPA – Complete Course


📈 29.59 Punkte

📌 Reboot and select proper boot device or Insert boot media in selected boot device and press a key


📈 29.1 Punkte

📌 Animated countdown in react with @react-spring/web


📈 28.45 Punkte

📌 how to save react form data into database using Spring boot


📈 28.01 Punkte

📌 This Week In React #127: Nextra, React-Query, React Documentary, Storybook, Remix, Tamagui, Solito, TC39, Rome...


📈 26.87 Punkte

📌 This Week In React #131: useReducer, Controlled Inputs, Async React, DevTools, React-Query, Storybook, Remix, RN , Expo...


📈 26.87 Punkte

📌 This Week In React #139: React.dev, Remix, Server Components, Error Boundary, Wakuwork, React-Native, Bottom Sheet...


📈 26.87 Punkte

📌 This Week In React #142: React-Query, Million, OpenNext, Ariakit, Expo-Image, React-Three-Fiber, TS 5.1, Node.js 20, WebGPU...


📈 26.87 Punkte

📌 This Week In React #146: Concurrency, Server Components, Next.js, React-Query, Remix, Expo Router, Skia, React-Native...


📈 26.87 Punkte

📌 Avoiding Pitfalls: Common Challenges in Backend Development with Spring Boot


📈 26.59 Punkte

📌 7 Major Reasons to Choose Spring Boot For Microservices Development


📈 26.59 Punkte

📌 Exploring the Magic of Spring Boot: Simplifying Java Development


📈 26.59 Punkte

📌 Full stack JavaScript today: Fastify, GraphQL, and React


📈 25.6 Punkte











matomo