olech2412 / MensaHub

MensaHub is a multi-component project that manages and provides Mensa-related data and services. It supports the dispatch of a newsletter and offers further processing of the data by means of an interface.
GNU General Public License v3.0
2 stars 0 forks source link

Bug: Fetching Meals also fetches Mensen #6

Closed olech2412 closed 1 year ago

olech2412 commented 1 year ago
[{"id":6,"name":"Gefüllte Paprikaschote","description":"Eier, Schwein, Rind, Salzkartoffeln, Jägersoße mit Champignons","price":"2,65€/ 4,40€/ 6,10€","category":"Fleischgericht","servingDate":"2023-02-06","responseCode":200,"rating":0.0,"votes":0,"starsTotal":0,"menseria_am_botanischen_garten":{"id":1,"name":"Menseria am Botanischen Garten","apiUrl":"https://openmensa.org/api/v2/canteens/72/meals"}}

Solution: Add the @JsonIgnore Annotation for each meal from import com.fasterxml.jackson.annotation.JsonIgnore;

olech2412 commented 1 year ago

Example Meals Class:

package com.example.demo.JPA.entities.meals;

import com.example.demo.JPA.entities.mensen.Mensa_Schoenauer_Str;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Setter
@Getter
@Entity
@Table(name = "meals_schoenauer_str")
public class Meals_Schoenauer_Str extends Meal {

    @ManyToOne
    @JoinColumn(name = "mensa_schoenauer_str_id", nullable = false)
    @JsonIgnore
    private Mensa_Schoenauer_Str mensa_schoenauer_str;

    public Meals_Schoenauer_Str() {

    }

}