i am creating exam portal in spring boot but i am stucked at one error which is as follows

here following is the code please give me the proper solution which will really work i have tried to run it multiple times but it is not working import com.exam.model.user; import com.exam.model.userRole; import com.exam.repo.RoleRepository; import com.exam.repo.UserRepository; import com.exam.service.UserService; import org.apache.catalina.Store; import org.springframework.beans.factory.annotation.Autowired; import java.util.Set; public class UserServiceImpl implements UserService { @Autowired private UserRepository userRepository; @Autowired… Read More i am creating exam portal in spring boot but i am stucked at one error which is as follows

Failed to load driver class org.h2.Driver from HikariConfig class classloader jdk.internal.loader.ClassLoaders$AppClassLoader

I am writing a little java project that is going to insert the tennis’ players data into the database. However, I am getting this error: 2023-02-25T15:52:06.800-05:00 ERROR 16196 — [ main] com.zaxxer.hikari.HikariConfig : Failed to load driver class org.h2.Driver from HikariConfig class classloader jdk.internal.loader.ClassLoaders$AppClassLoader@4d7e1886 Which leads to this error: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name… Read More Failed to load driver class org.h2.Driver from HikariConfig class classloader jdk.internal.loader.ClassLoaders$AppClassLoader

SQL query doesn't work with strings params using nativeQuery

The code that is given below @Query(nativeQuery = true, value = "SELECT * FROM devices WHERE date(date_of_add) = %?1%", countQuery = "SELECT count(*) FROM devices WHERE date(date_of_add) = %?1%") Page<Device> findAllByDate(String date, Pageable pageable); Brings to an error org.hibernate.QueryException: JPA-style positional param was not an integral ordinal I tried a lot of different options for… Read More SQL query doesn't work with strings params using nativeQuery

How to retrieve all user information except passwords

I implemented a basic JPA authentication following this tutorial. I wanted to create an endpoint /mydetails to display user information (profile info). What I’ve tried: @GetMapping("/mydetails") public Optional<User> getUser(HttpServletRequest request) { Optional<User> foundUser = Optional.ofNullable(userRepo.getUserByUsername(request.getUserPrincipal().getName())); return foundUser; } Outcome: { "id":1, "username":"name.surname@companyname.com", "password":"$2a$10$7YzUO6scaC06LV6IgOsSXetFm4/U0WM.UZykhRfQcJBzKacyZFMK", "first_name":"John", "last_name":"Walker", "organization_name":"ABC", "role":"Admin", "credibility_rating":"100" } The problem is that this literally… Read More How to retrieve all user information except passwords

Select phrases ordered by frequency

@Entity @Table(name = "clusters", uniqueConstraints = {@UniqueConstraint(name = "unique_cluster_name", columnNames = {"clusterName"})}) @Builder @Getter @Setter @NoArgsConstructor @AllArgsConstructor public class ClusterEntity extends BaseEntity { @OneToMany(mappedBy = "cluster", cascade = CascadeType.REMOVE) private List<CorePhraseEntity> phrases = new ArrayList<>(); } ​ ​ ​ @Entity @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder @Table(name = "phrases", uniqueConstraints = {@UniqueConstraint(name = "unique_phrase", columnNames =… Read More Select phrases ordered by frequency

Spring Boot Project Is Not Running Due To Version Issues

This is my pom xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.0.1</version> <relativePath/> <!– lookup parent from repository –> </parent> <groupId>com.csmtech</groupId> <artifactId>ExcelDataBase</artifactId> <version>0.0.1-SNAPSHOT</version> <name>ExcelDataBase</name> <description>Excel To DB Convert</description> <properties> <java.version>17</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId>… Read More Spring Boot Project Is Not Running Due To Version Issues

jakarta.persistence.TransactionRequiredException: Executing an update/delete query

I use spring boot 3.0.0, I try to use query.executeUpdate() method . There is my code: @Transactional public void UpdatePassageByNiveau(int niveau, String cin) { String queryRecherche = "UPDATE Passage p SET p.dateDebut = p.dateDebut + 1 year, " + "p.dateFin = p.dateFin + 1 year WHERE resident.cin = :cin and p.niveau = :niveau "; Query… Read More jakarta.persistence.TransactionRequiredException: Executing an update/delete query

If I add spring-boot-starter-data-jpa to a simple spring application I get 404s but none if it's not there

I am trying to debug why a my application won’t show, and in doing so I have this small application running hello world. This does work, it shows the text on the screen, great. But then if I add spring-boot-starter-data-jpa to the pom file, I get a 404 error instead. I need to use spring-boot-starter-data-jpa… Read More If I add spring-boot-starter-data-jpa to a simple spring application I get 404s but none if it's not there