user entity board entity When I try to fetch data using findAll method I get infinite json object. For example when I fetch users I have set of boards inside it I have set of users and inside it I have set of boards… etc. How can I fetch user with his boards and boards with its users ? Answer
Tag: spring
How to send PUT/PATCH/DELETE requests in thymeleaf template?
How can I send a DELETE request with thymeleaf? I tried as follows: But all that I get is: org.springframework.web.HttpRequestMethodNotSupportedException: Request method ‘POST’ not supported Answer If you are using Spring Boot 2.2+, you need to enable support for this explictly. Add the following …
Is there a way in which we can check for presence of data in application.properties file in Spring Boot Project before the tomcat server starts?
I am writing a Spring Boot project to Run a Cloud Config Server and 3 Micro-services to run as a Client. I would want to check availability of all properties in application.properties or yaml file before starting the tomcat server. We already have a similar one for Database Startup Validation, but here I am t…
Java spring Hibernate : Error when trying to implement a many to one relationship
I am trying to implement a many to one relationship with a user being able to have many posts. The used database is postgresql. The error I have is the following and is caused by Hibernate: alter table post drop constraint FKl1p5mt95jngsghp4vtaw04egh : These are the 2 classes I use : and The error occurs at t…
How to call @RestControllerAdvice class from a unit test in the Service layer of a REST web service in java?
I have a REST webservice application. I am handling exceptions by exception handler using the annotation @ExceptionHandler and @RestControllerAdvice. My exceptions are thrown in the Service layer. Now I am writing unit tests for the service layer. I am checking the exceptions using Assert.assertThrows. The ex…
Unsatisfied dependency through ‘sessionFactory’; No qualifying bean of type ‘org.hibernate.SessionFactory’ available
I am creating a spring-mvc and hibernate webapp. I am trying to test text read in the book by creating project (hence using xml config). This type of question is asked before but I can’t get my project to work with answers offered. I get following error when I hit the end-point : Here is @Configuration …
I have an error but dependencies include in gradle root and gradle module config, why?
I have root config gradle.build and have build.gradle in module After download dependencies and add in models annotations like @Entity, @Table @Id and etc. i have an error: cannot find symbol @Entity ^ symbol: class Entity But i have spring-boot-starter-jpa in dependencies, i don’t know why in module i …
Spring JPA repository interface and default methods use case
I am currently wondering whether a particular use case could be elegantly addressed by using a default interface method inside a JPA repository. Suppose we have the following entity and supporting types: I need to be able to query a list of SomeEntity based on combination of Status enumeration values. With Sp…
Property or field ‘id’ cannot be found on object of type ‘java.lang.Boolean’ – maybe not public or not valid?
I am writing a SpringBoot application for an e-commerce website project where I’m creating a form to change the current password of the user account. I am getting the following two errors when the form gets submitted. ERROR-1 ERROR-2 HomeController myprofile.html User Class User Service User Service Imp…
spring boot security not configured properly
I am new to Spring boot and Spring boot security. However, using the existing sample codes, I had written a code which worked correctly. In my design, I had a separate page for my login, called login….