Hello I am a beginner at Spring Boot and have been trying to work through a 500 error when trying to access an endpoint. I do have data in an mysql database that I am trying to fetch.
Here is an example of the Entity I am trying to get.
package com.example.demo.Entities;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Entity
@Table(name = "vacations")
public class Vacation {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="vacation_id")
private Long id;
@Column(name = "vacation_title")
private String vacation_title;
@Column(name = "description")
private String description;
@Column(name = "travel_price")
private BigDecimal travel_price;
@Column(name = "image_url")
private String image_URL;
@Column(name = "create_date")
@CreationTimestamp
private Date create_date;
@Column(name = "last_update")
@UpdateTimestamp
private Date last_update;
@OneToMany
private Set<Excursion> excursions;
public Vacation() {}
}
Here is the the JpaRepository:
package com.example.demo.DAO;
import com.example.demo.Entities.Vacation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.CrossOrigin;
@Repository
@CrossOrigin("http://localhost:4200")
public interface VacationRepository extends JpaRepository<Vacation, Long> { }
I can run localhost:8080/api and that will work just fine showing verything past /api but when I do api/vacations it return an error 500. Any help with this problem would be appreciated.