Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Country.java package com.shahin.fleetapp.model; import java.util.List; import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.ObjectIdGenerators; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.OneToMany; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor;

image text in transcribed

Country.java

package com.shahin.fleetapp.model;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;

import com.fasterxml.jackson.annotation.ObjectIdGenerators;

import jakarta.persistence.Entity;

import jakarta.persistence.GeneratedValue;

import jakarta.persistence.GenerationType;

import jakarta.persistence.Id;

import jakarta.persistence.OneToMany;

import lombok.AllArgsConstructor;

import lombok.Data;

import lombok.NoArgsConstructor;

@Entity

@Data

@NoArgsConstructor

@AllArgsConstructor

@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")

public class Country {

@Id

@GeneratedValue(strategy = GenerationType.IDENTITY)

private Integer id;

private String code;

private String capital;

private String description;

private String nationality;

private String continent;

@OneToMany(mappedBy="country")

private List states;

}

----------------------------------

CountryService.java

package com.shahin.fleetapp.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

import com.shahin.fleetapp.model.Country;

import com.shahin.fleetapp.repositories.CountryRepository;

@Service

public class CountryService {

@Autowired

private CountryRepository countryRepo;

//Return List of countries

public List findAll(){

return countryRepo.findAll();

}

}

--------------------------------------------

CountryRepository

package com.shahin.fleetapp.repositories;

import org.springframework.data.jpa.repository.JpaRepository;

import org.springframework.stereotype.Repository;

import com.shahin.fleetapp.model.Country;

@Repository

public interface CountryRepository extends JpaRepository {

}

Can you please help me to fix this error?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started