Changement mongo
This commit is contained in:
@@ -24,17 +24,14 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
|
||||||
testImplementation 'org.springframework.security:spring-security-test'
|
|
||||||
compileOnly 'org.projectlombok:lombok'
|
compileOnly 'org.projectlombok:lombok'
|
||||||
developmentOnly 'org.springframework.boot:spring-boot-devtools'
|
|
||||||
annotationProcessor 'org.projectlombok:lombok'
|
annotationProcessor 'org.projectlombok:lombok'
|
||||||
|
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
runtimeOnly 'com.microsoft.sqlserver:mssql-jdbc'
|
|
||||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||||
|
implementation 'jakarta.persistence:jakarta.persistence-api:3.1.0'
|
||||||
|
|
||||||
testCompileOnly 'org.projectlombok:lombok'
|
testCompileOnly 'org.projectlombok:lombok'
|
||||||
testAnnotationProcessor 'org.projectlombok:lombok'
|
testAnnotationProcessor 'org.projectlombok:lombok'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,29 @@
|
|||||||
package fr.eni.demo.bo;
|
package fr.eni.demo.bo;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Field;
|
||||||
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ToString
|
|
||||||
@Builder
|
@Builder
|
||||||
|
@Document(collection = "address")
|
||||||
@Entity
|
|
||||||
@Table(name="ADRESSES")
|
|
||||||
public class Adresse {
|
public class Adresse {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
@Column(name = "ADRESSE_ID")
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@Column(name = "STREET",nullable = false, length = 250)
|
@Field(name = "STREET")
|
||||||
private String rue;
|
private String rue;
|
||||||
|
|
||||||
@Column(name = "POSTAL_CODE",nullable = false, length = 5)
|
@Field(name = "POSTAL_CODE")
|
||||||
private String codePostal;
|
private String codePostal;
|
||||||
|
|
||||||
@Column(name = "CITY",nullable = false, length = 150)
|
@Field(name = "CITY")
|
||||||
private String ville;
|
private String ville;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
package fr.eni.demo.bo;
|
package fr.eni.demo.bo;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Field;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -9,31 +12,27 @@ import java.util.List;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ToString(exclude = "locations")
|
|
||||||
@Builder
|
@Builder
|
||||||
|
@Document(collection = "clients")
|
||||||
@Entity
|
|
||||||
@Table(name="CLIENTS")
|
|
||||||
public class Client {
|
public class Client {
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
@Column(name = "CLIENT_ID")
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
@Column(name= "LAST_NAME", nullable = false, length = 90)
|
@Id
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Field(name = "LAST_NAME")
|
||||||
private String nom;
|
private String nom;
|
||||||
|
|
||||||
@Column(name= "FIRST_NAME", nullable = false, length = 150)
|
@Field(name = "FIRST_NAME")
|
||||||
private String prenom;
|
private String prenom;
|
||||||
|
|
||||||
@Column(nullable = false, unique = true)
|
@Field(name = "EMAIL")
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, optional = false)
|
@DBRef
|
||||||
@JoinColumn(name = "ADRESSE_ID")
|
@Field(name = "ADRESSE")
|
||||||
private Adresse adresse;
|
private Adresse adresse;
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
@DBRef
|
||||||
@JoinColumn(name = "CLIENT_ID")
|
@Field(name = "LOCATIONS")
|
||||||
private List<Location> locations;
|
private List<Location> locations;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,21 @@
|
|||||||
package fr.eni.demo.bo;
|
package fr.eni.demo.bo;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Field;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ToString
|
|
||||||
@Builder
|
@Builder
|
||||||
|
@Document(collection = "game_type")
|
||||||
@Entity
|
|
||||||
@Table(name="GAME_TYPE")
|
|
||||||
public class GameType {
|
public class GameType {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
private String id;
|
||||||
@Column(name = "GAME_TYPE_ID")
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
@Column(name="GAME_TYPE_NAME", nullable = false)
|
@Field(name = "GAME_TYPE_NAME")
|
||||||
private String name;
|
private String name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package fr.eni.demo.bo;
|
package fr.eni.demo.bo;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Field;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -9,29 +12,24 @@ import java.util.Date;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ToString(exclude = {"client", "stock"})
|
|
||||||
@Builder
|
@Builder
|
||||||
|
@Document(collection = "locations")
|
||||||
@Entity
|
|
||||||
@Table(name="LOCATIONS")
|
|
||||||
public class Location {
|
public class Location {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
private String id;
|
||||||
@Column(name="LOCATION_ID")
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
@Column(name = "LOCATION_START_DATE", nullable = false)
|
@Field(name = "LOCATION_START_DATE")
|
||||||
private Date startDate;
|
private Date startDate;
|
||||||
|
|
||||||
@Column(name = "LOCATION_END_DATE")
|
@Field(name = "LOCATION_END_DATE")
|
||||||
private Date endDate;
|
private Date endDate;
|
||||||
|
|
||||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
@DBRef
|
||||||
@JoinColumn(name = "CLIENT_ID", nullable = false)
|
@Field(name = "CLIENT")
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
@DBRef
|
||||||
@JoinColumn(name = "GAME_ID", nullable = false)
|
@Field(name = "STOCK")
|
||||||
private Stock stock;
|
private Stock stock;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package fr.eni.demo.bo;
|
package fr.eni.demo.bo;
|
||||||
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Field;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -10,39 +12,30 @@ import java.util.List;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ToString
|
|
||||||
@Builder
|
@Builder
|
||||||
|
@Document(collection = "stock")
|
||||||
@Entity
|
|
||||||
@Table(name="GAME")
|
|
||||||
public class Stock {
|
public class Stock {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
private String id;
|
||||||
@Column(name = "GAME_ID")
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
@Column(name="GAME_NAME", nullable = false)
|
@Field(name = "GAME_NAME")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Column(name="GAME_DESCRIPTION")
|
@Field(name = "GAME_DESCRIPTION")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Column(name="GAME_REF", nullable = false)
|
@Field(name = "GAME_REF")
|
||||||
private String ref;
|
private String ref;
|
||||||
|
|
||||||
@Column(name="GAME_DAILY_PRICE", nullable = false)
|
@Field(name = "GAME_DAILY_PRICE")
|
||||||
private Double dailyPrice;
|
private Double dailyPrice;
|
||||||
|
|
||||||
@ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
|
@DBRef
|
||||||
@JoinTable(
|
@Field(name = "GAME_TYPE")
|
||||||
name = "STOCK_GAME_TYPE",
|
|
||||||
joinColumns = @JoinColumn(name = "GAME_ID"), // Clé étrangère vers Stock
|
|
||||||
inverseJoinColumns = @JoinColumn(name = "GAME_TYPE_ID") // Clé étrangère vers GameType
|
|
||||||
)
|
|
||||||
private List<GameType> gameType;
|
private List<GameType> gameType;
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
@DBRef
|
||||||
@JoinColumn(name = "GAME_ID")
|
@Field(name = "LOCATIONS")
|
||||||
private List<Location> locations;
|
private List<Location> locations;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package fr.eni.demo.dal;
|
package fr.eni.demo.dal;
|
||||||
|
|
||||||
import fr.eni.demo.bo.Adresse;
|
import fr.eni.demo.bo.Adresse;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface AdresseRepository extends JpaRepository<Adresse, Long> {
|
public interface AdresseRepository extends MongoRepository<Adresse, Long> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package fr.eni.demo.dal;
|
package fr.eni.demo.dal;
|
||||||
|
|
||||||
import fr.eni.demo.bo.Client;
|
import fr.eni.demo.bo.Client;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface ClientRepository extends JpaRepository<Client, Long> {
|
public interface ClientRepository extends MongoRepository<Client, Long> {
|
||||||
List<Client> findByPrenomIgnoreCaseContainingOrNomIgnoreCaseContaining(String prenom, String nom);
|
List<Client> findByPrenomIgnoreCaseContainingOrNomIgnoreCaseContaining(String prenom, String nom);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package fr.eni.demo.dal;
|
package fr.eni.demo.dal;
|
||||||
|
|
||||||
import fr.eni.demo.bo.GameType;
|
import fr.eni.demo.bo.GameType;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface GameTypeRepository extends JpaRepository<GameType, Long> {
|
public interface GameTypeRepository extends MongoRepository<GameType, Long> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package fr.eni.demo.dal;
|
package fr.eni.demo.dal;
|
||||||
|
|
||||||
import fr.eni.demo.bo.Location;
|
import fr.eni.demo.bo.Location;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface LocationRepository extends JpaRepository<Location, Integer> {
|
public interface LocationRepository extends MongoRepository<Location, Integer> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package fr.eni.demo.dal;
|
package fr.eni.demo.dal;
|
||||||
|
|
||||||
import fr.eni.demo.bo.Stock;
|
import fr.eni.demo.bo.Stock;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface StockRepository extends JpaRepository<Stock,Long> {
|
public interface StockRepository extends MongoRepository<Stock,Long> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,6 @@
|
|||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: ENI-ludotheque
|
name: ENI-ludotheque
|
||||||
#Connection to DB
|
|
||||||
datasource:
|
|
||||||
url: jdbc:sqlserver://localhost;databasename=LUDO_DB;integratedSecurity=false;encrypt=false;trustServerCertificate=false
|
|
||||||
username: LUDO_USER
|
|
||||||
password: LUDO_PWD
|
|
||||||
|
|
||||||
#Options to DB
|
|
||||||
jpa:
|
|
||||||
show-sql: true
|
|
||||||
properties:
|
|
||||||
hibernate:
|
|
||||||
format_sql: true
|
|
||||||
hibernate:
|
|
||||||
ddl-auto: create
|
|
||||||
|
|
||||||
data:
|
data:
|
||||||
mongodb:
|
mongodb:
|
||||||
|
|||||||
Reference in New Issue
Block a user