Backend não está rodando

Bom dia!
Estou com problema backend não está rodando.

erro na linha - private Set scores = new HashSet<>();
MENSAGEM: The type Set is not generic; it cannot be parameterized with arguments

erro na linha - private Set getScores() {
return scores;
}
MENSAGEM: The type Set is not generic; it cannot be parameterized with arguments

Classe1 erro:

package com.devsuperior.dsmovie.entities;

import java.util.HashSet;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.mapping.Set;

@Entity
@Table(name = “tb_movie”)
public class Movie {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String title;
private Double score;
private Integer count;
private String image;


@OneToMany(mappedBy = "id.movie")

private Set<Score> scores = new HashSet<>();

public Movie() {
	}

public Movie(Long id, String title, Double score, Integer count, String image) {
	this.id = id;
	this.title = title;
	this.score = score;
	this.count = count;
	this.image = image;
	
}

public Long getId() {
	return id;
}

public void setId(Long id) {
	this.id = id;
}

public String getTitle() {
	return title;
}

public void setTitle(String title) {
	this.title = title;
}

public Double getScore() {
	return score;
}

public void setScore(Double score) {
	this.score = score;
}

public Integer getCount() {
	return count;
}

public void setCount(Integer count) {
	this.count = count;
}

public String getImage() {
	return image;
}

public void setImage(String image) {
	this.image = image;
}


private Set<Score> getScores() {
	return scores;
}

}


Classe2

package com.devsuperior.dsmovie.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.devsuperior.dsmovie.dto.MovieDto;
import com.devsuperior.dsmovie.dto.ScoreDto;
import com.devsuperior.dsmovie.entities.Movie;
import com.devsuperior.dsmovie.entities.Score;
import com.devsuperior.dsmovie.entities.User;
import com.devsuperior.dsmovie.repositories.MovieRepository;
import com.devsuperior.dsmovie.repositories.ScoreRepository;
import com.devsuperior.dsmovie.repositories.UserRepository;

@Service
public class ScoreService {

    @Autowired
	private MovieRepository movieRepository;
	
    @Autowired
	private UserRepository userRepository;
    
    @Autowired
	private ScoreRepository ScoreRepository;
	
	@Transactional
    public MovieDto saveScore(ScoreDto dto) {
     
		User user = userRepository.findByEmail(dto.getEmail());
		if (user == null) {
	    user = new User();
	    user.setEmail(dto.getEmail());
	    user = userRepository.saveAndFlush(user);
	    }
		
		Movie movie = movieRepository.findById(dto.getMovieId()).get();
		
		Score score = new Score();
		score.setMovie(movie);
		score.setUser(user);
		score.setValue(dto.getScore());
		
		score = ScoreRepository.saveAndFlush(score);
		
		Double sum = 0.0;
		for (Score s : movie.getScores()) {
	    sum = sum + s.getValue();
		}
		double avg = sum / movie.getScores().size();
		
		movie.setScore(avg);
		movie.setCount(movie.getScores().size());
		
		movie = movieRepository.save(movie);
		
		return new MovieDto(movie);
		
		}
    }

erro na linha: double avg = sum / movie.getScores().size();
MENSAGEM: The method getScores() from the type Movie is not visible
Pacote Service

Você está fazendo import de

org.hibernate.mapping.Set

Deveria ser de

java.util.Set

Staroski boa noite,

Muito obrigado deu certo, valeu!!

1 curtida