0% found this document useful (0 votes)
10 views1 page

Lase9 - SysDistributed - Part 2

The document provides an overview of Hibernate annotations and Spring Boot project structure, detailing how to associate Java classes with database tables using annotations like @Entity and @Table. It also outlines the repository pattern for executing CRUD operations with JpaRepository and includes configuration settings for a Spring Boot application. Key annotations such as @SpringBootApplication and @Repository are highlighted for their roles in application setup and data management.

Uploaded by

sadiqizakariyae
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Lase9 - SysDistributed - Part 2

The document provides an overview of Hibernate annotations and Spring Boot project structure, detailing how to associate Java classes with database tables using annotations like @Entity and @Table. It also outlines the repository pattern for executing CRUD operations with JpaRepository and includes configuration settings for a Spring Boot application. Key annotations such as @SpringBootApplication and @Repository are highlighted for their roles in application setup and data management.

Uploaded by

sadiqizakariyae
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

LASE9 - Distributed Systems

Hibernate Annotation Exemple :


@Entity associer une classe Java à une table base de @Entity

@Table(name = “users”)

données.
public class User {

@Table(name = “users”) spécifie le nom de la table @Id

associé @GeneratedValue(strategy = GenerationType.AUTO)

@Id indique la clé primaire de l’entité private Long id;

@GenerativeValue utilisée avec @Id pour générer les private String username;

@Column(name=”email”,nullable=false,length=50)

valeurs private String email; // Getters and setters

@Column(name = “email”) spécifie le nom, et les }


caracteristiques d’une colonne

Spring Boot
Project Package Name resources application.propreties
main Repositories
Models
Controllers
Services

Repositories @Repository public interface UserRepository extends JpaRepository<User, Long>{

@Query(value =”SELECT * FROM user WHERE name = ?”)

Interfaces JpaRepositories permet d’executer

List<User> findByNale(String name);

les fonctions CRUD, ainsi que des methodes


}
spécifiques

application.propreties Main application


server.port=9091
@SpringBootApplication

spring.datasource.url=jdbc:mysql://localhost:3306/project
public class HrBackendApplication {

spring.datasource.username=root
public static void main(String[] args) {

spring.datasource.password=
SpringApplication.run(HrBackendApplication.class, args);

spring.datasource.platform=mysql
}

spring.jpa.hibernate.ddl-auto=update }

@SpringBootApplication un regroupement d’un ensemble

des annotations
@Configuratio
@EnableAutoConfiguratio
@EnableWebMv
@ComponentScan analyse des changement

You might also like