update
This commit is contained in:
@@ -30,6 +30,13 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey</groupId>
|
||||
<artifactId>jersey-bom</artifactId>
|
||||
<version>3.1.5</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
@@ -72,6 +79,59 @@
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.10.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>2.0.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>5.17.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JAX-RS (Jersey) -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.inject</groupId>
|
||||
<artifactId>jersey-hk2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-json-jackson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- H2 Database (pour tests, sinon MySQL/PostgreSQL) -->
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>2.2.224</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- Servlet API -->
|
||||
<dependency>
|
||||
<groupId>jakarta.servlet</groupId>
|
||||
<artifactId>jakarta.servlet-api</artifactId>
|
||||
<version>6.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<version>11.0.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>11.0.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-servlet</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class App {
|
||||
|
||||
SessionFactory sessionFactory;
|
||||
|
||||
if (HibernateConfig.LOCAL) sessionFactory = HibernateConfig.getSessionFactory();
|
||||
if (HibernateConfig.isLocalEnvironment()) sessionFactory = HibernateConfig.getSessionFactory();
|
||||
|
||||
else {
|
||||
StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
|
||||
|
||||
@@ -7,13 +7,13 @@ import org.reflections.Reflections;
|
||||
import jakarta.persistence.Entity;
|
||||
|
||||
public class HibernateConfig {
|
||||
|
||||
private static final SessionFactory sessionFactory;
|
||||
public static final boolean LOCAL = true;
|
||||
private static final boolean LOCAL = true;
|
||||
private static String url;
|
||||
private static String username;
|
||||
private static String password;
|
||||
|
||||
|
||||
static {
|
||||
|
||||
if (LOCAL) {
|
||||
@@ -46,5 +46,9 @@ public class HibernateConfig {
|
||||
public static SessionFactory getSessionFactory() {
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
public static boolean isLocalEnvironment() {
|
||||
return LOCAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public abstract class GenericDaoImpl<T, ID> implements GenericDao<T, ID> {
|
||||
public void delete(ID id) {
|
||||
try (Session session = sessionFactory.openSession()) {
|
||||
session.beginTransaction();
|
||||
T entity = session.get(entityClass, id);
|
||||
T entity = session.find(entityClass, id);
|
||||
if (entity != null) session.remove(entity);
|
||||
session.getTransaction().commit();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.humanbooster.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -11,7 +12,10 @@ public class User {
|
||||
@GeneratedValue (strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
private String name;
|
||||
|
||||
@NotNull
|
||||
private String email;
|
||||
|
||||
@OneToMany(mappedBy="author", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
|
||||
Reference in New Issue
Block a user