title: I have created a spring boot with DTO, Entity and also not able to store it
body: <p>I have created a spring boot with DTO, Entity and also generating entity from dto and vice versa but the data is not getting stored in the Postgres sql when i am trying to get the data its is showing null but creation is happing
  <strong>First is the controller class</strong></p>
  <pre><code>import com.school.Entity.StudentDetails;
  import com.school.Service.StudentService;
  import com.school.dto.StudentDetailDto;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.*;
  
  import java.util.List;
  
  @RestController
  @RequestMapping(&quot;/api&quot;)
  @CrossOrigin(&quot;*&quot;)
  public class SchoolController {
  
      @Autowired
      StudentService studentService;
  
      @GetMapping(&quot;/test&quot;)
      public String test(){
          return &quot;test&quot;;
      }
      @PostMapping(&quot;/uploadStudentData&quot;)
      public StudentDetailDto createStudentDetails(@RequestBody StudentDetailDto dto){
          return studentService.createStudentDetails(dto);
      }
      @GetMapping(&quot;/getAll&quot;)
      public List&lt;StudentDetails&gt; getAllStudentData(){
          return studentService.getAllStudentData();
      }
  }
  
  </code></pre>
  <p><strong>Now the StudentDetailDto class</strong></p>
  <pre><code>import java.util.List;
  
  public class StudentDetailDto {
      private Long id;
      private String branch;
      private List&lt;StudentDto&gt; student;
  
      //getter and setter
  }
  
  </code></pre>
  <p><strong>now the StudenDto class</strong></p>
  <pre><code>public class StudentDto {
      private Long id;
      private String firstName;
      private String lastName;
      private List&lt;MarksListDto&gt; marksList;
  // getter and setter
  }
  </code></pre>
  <p><strong>now the marks list class</strong></p>
  <pre><code>public class MarksListDto {
      private Long id;
      private String subjectName;
      private Integer marks;
  // getter and setter
  }
  </code></pre>
  <p><strong>now the SchoolDetails entity class</strong></p>
  <pre><code>@Entity
  public class StudentDetails {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
      private String branch;
      @OneToMany(targetEntity=Students.class, mappedBy=&quot;id&quot;, fetch=FetchType.EAGER,cascade=CascadeType.ALL)
      private List&lt;Students&gt; student;
  //getter and setter
  }
  </code></pre>
  <p><strong>Now the Student Entity class</strong></p>
  <pre><code>@Entity
  public class Students {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
      private String firstName;
      private String lastName;
      @OneToMany(targetEntity=MarksList.class, mappedBy=&quot;id&quot;, fetch=FetchType.EAGER,cascade=CascadeType.ALL)
      private List&lt;MarksList&gt; marksList;
  //getter and setter
  }
  
  </code></pre>
  <p><strong>Now the marks list entity</strong></p>
  <pre><code>@Entity
  public class MarksList {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
      private String subjectName;
      private int marks;
  //getter and setter
  }
  </code></pre>
  <p><strong>Repository</strong></p>
  <pre><code>public interface StudentRepository extends JpaRepository&lt;StudentDetails, Long&gt; {
  }
  </code></pre>
  <p><strong>Now the most important that i am thinking there is something wrong is the servers</strong></p>
  <pre><code>import com.school.Entity.StudentDetails;
  import com.school.Repository.StudentRepository;
  import com.school.dto.StudentDetailDto;
  import org.modelmapper.ModelMapper;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  import java.util.ArrayList;
  import java.util.List;
  
  
  @Service
  public class StudentService {
      @Autowired
      StudentRepository studentRepository;
  
      @Autowired
      ModelMapper modelMapper;
  
      public StudentDetailDto createStudentDetails(StudentDetailDto dto) {
          validateDto(dto);
          StudentDetails studentDetails = generateEntityFromDto(dto);
          studentDetails = studentRepository.save(studentDetails);
          return generateDtoFromEntity(studentDetails);
      }
  
      private StudentDetails generateEntityFromDto(StudentDetailDto dto) {
          StudentDetails studentDetails = modelMapper.map(dto, StudentDetails.class);
          return studentDetails;
      }
  
      private StudentDetailDto generateDtoFromEntity(StudentDetails studentDetails){
          StudentDetailDto dto = modelMapper.map(studentDetails,StudentDetailDto.class);
          return dto;
      }
  
      private void validateDto(StudentDetailDto dto) {
  
      }
  
  //    public List&lt;StudentDetailDto&gt; getAllStudentData() {
  //        List&lt;StudentDetailDto&gt; dto = new ArrayList&lt;&gt;();
  //         studentRepository.findAll().forEach(dto::add);
  //         return dto;
  //    }
  //    public String createStudentDetails(StudentDetails studentDetails){
  //        studentRepository.save(studentDetails);
  //        return &quot;Student details created&quot;;
  //    }
  //
      public List&lt;StudentDetails&gt; getAllStudentData() {
          return new ArrayList&lt;&gt;(studentRepository.findAll());
  
      }
  }
  </code></pre>
  <p><strong>So when i am sending the data in postman it's showing me this it is storing null value i don't now y can anyone help me fix this and can help me to improve the code to the best version</strong></p>
  <p><img src="https://i.ibb.co/0K3wBR6/Screenshot-3.png" alt="postman image" /></p>