Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql Jackson@JsonIgnore注释-关系值不';我不能回来_Mysql_Hibernate_Jakarta Ee - Fatal编程技术网

Mysql Jackson@JsonIgnore注释-关系值不';我不能回来

Mysql Jackson@JsonIgnore注释-关系值不';我不能回来,mysql,hibernate,jakarta-ee,Mysql,Hibernate,Jakarta Ee,我有一个mysql数据库,从中我使用Hibernate生成了TransferObject。城市与患者、城市与医生、专业与医生之间存在一对多的关系。但是,当从这些一对多关系查询数据库时,我没有得到任何返回值 当我测试RestFul端点时,我得到: /医生/所有 [{"id":1,"email":"papa@papa.com","fatherName":"πατέρας","firstName":"όνομα","lastName":"επίθετο","telephone":"2821074737

我有一个mysql数据库,从中我使用Hibernate生成了TransferObject。城市与患者、城市与医生、专业与医生之间存在一对多的关系。但是,当从这些一对多关系查询数据库时,我没有得到任何返回值

当我测试RestFul端点时,我得到:

/医生/所有

[{"id":1,"email":"papa@papa.com","fatherName":"πατέρας","firstName":"όνομα","lastName":"επίθετο","telephone":"2821074737"},{"id":2,"email":"lala@gmail.com","fatherName":"dfjs","firstName":"Ιωσήφ","lastName":"Βαρουξάκης","telephone":"8583848824"},{"id":3,"email":"","fatherName":"","firstName":"Χαράλαμπος","lastName":"Πρωτοπαπαδάκης","telephone":"4343454345"},{"id":4,"email":"","fatherName":"","firstName":"Ελευθέριος","lastName":"Παπαδάκης","telephone":"2821084834"},{"id":5,"email":"","fatherName":"","firstName":"Παναγιώτης","lastName":"Τζεράκης","telephone":"28210848383"},{"id":6,"email":"","fatherName":"","firstName":"Κων/νος","lastName":"Κωνσταντινίδης","telephone":"2821084838"},{"id":7,"email":"","fatherName":"","firstName":"Παναγιώτης","lastName":"Ψιστάκης","telephone":"2810838383"},{"id":8,"email":"","fatherName":"Εμμανουήλ","firstName":"Θεανώ","lastName":"Πατακάκη","telephone":"2821048438"},{"id":9,"email":"","fatherName":"","firstName":"Μαρία","lastName":"Καφούση","telephone":"2810848283"},{"id":10,"email":"","fatherName":"","firstName":"Μανούσος","lastName":"Χριστοδουλάκης","telephone":"2810848383"},{"id":11,"email":"saf@fdsa.gr","fatherName":"αφδσ","firstName":"φδσα","lastName":"σφδ","telephone":"2323233223"},{"id":12,"email":"","fatherName":"φεδσαφ","firstName":"φδσαφδσα","lastName":"φδσαφγσφαδ","telephone":"3333333333"},{"id":13,"email":"mixtou@gmail.co","fatherName":"Dimitrios","firstName":"Toutoudakis","lastName":"Mixail","telephone":"6948571893"}]
/病人/全部

[{"id":1,"birthday":"1975-08-19","email":"mixtou@gmail.com","fatherName":"Δημήτριος","firstName":"Μιχαήλ","lastName":"Τουτουδάκης","telephone":"6948571893","sex":true},{"id":2,"birthday":"1942-06-10","email":"lla@gmail.com","fatherName":"Μιχαήλ","firstName":"Δημήτριος","lastName":"Τουτουδάκης","telephone":"7364927473","sex":true},{"id":3,"birthday":"1975-05-06","email":"lala@gmail.com","fatherName":"Μιχαήλ","firstName":"Μιχαήλ","lastName":"Μαραγκάκης","telephone":"8484848484","sex":false},{"id":4,"birthday":"1957-08-14","email":"lasdjf@lkdafs.gr","fatherName":"Τεστ","firstName":"Μηνάς","lastName":"Παπαδάκης","telephone":"8484842747","sex":false},{"id":5,"birthday":"2018-03-26","email":"","fatherName":"","firstName":"Στέφανος","lastName":"Μαριόλος","telephone":"4838583845","sex":true},{"id":6,"birthday":"2018-03-20","email":"jkdas@gjal.com","fatherName":"Μ..κας","firstName":"Κων/νος","lastName":"Μπλαζάκης","telephone":"2347878763","sex":false},{"id":7,"birthday":"2018-03-08","email":"ajs@gjla;.gr","fatherName":"pateras","firstName":"f;ldas","lastName":"akdfsj","telephone":"445354345453","sex":true},{"id":8,"birthday":"2018-03-12","email":"lala@gam.gr","fatherName":"Εμμανουήλ","firstName":"Ιωάννης","lastName":"Μαλανδράκης","telephone":"4343434343","sex":false},{"id":9,"birthday":"1980-05-12","email":"antonis@gmai.com","fatherName":"Δεν Ξέρω","firstName":"Αντώνιος","lastName":"Ιγγλεζάκης","telephone":"28210848484","sex":false},{"id":10,"birthday":"2018-04-19","email":"test@etes.gr","fatherName":"test","firstName":"test`","lastName":"tet","telephone":"2345674424","sex":false},{"id":11,"birthday":"1984-02-13","email":"lala@gmail.com","fatherName":"Δημήτριος","firstName":"Ιωάννης","lastName":"Μαλανδράκης","telephone":"1223323344","sex":false},{"id":12,"birthday":"2018-05-16","email":"lala@gmail.com","fatherName":"Τεεε","firstName":"Τέστης","lastName":"Τεστάκης","telephone":"84848484823","sex":false},{"id":13,"birthday":"2018-06-05","email":"lala@gmail.com","fatherName":"test","firstName":"test","lastName":"test","telephone":"2821022222","sex":true}]
/城市/所有

[{"id":4,"name":"Αγ. Νικόλαος"},{"id":3,"name":"Ηράκλειο"},{"id":2,"name":"Ρέθυμνο"},{"id":5,"name":"Ρόδος"},{"id":1,"name":"Χανιά"}]
/特色/全部

[{"id":1,"name":"Αγγειοχειρουργική"},{"id":2,"name":"Αιματολογία"},{"id":3,"name":"Ακτινοδιαγνωστική"},{"id":4,"name":"Ακτινοθεραπευτική"},{"id":5,"name":"Αλλεργιολογία"},{"id":6,"name":"Αναισθησιολογία"},{"id":7,"name":"Γαστρεντερολογία"},{"id":8,"name":"Γενική Ιατρική"},{"id":9,"name":"Δερματολογία"},{"id":10,"name":"Ενδοκρινολογία"},{"id":12,"name":"Ιατρική Εργασίας"},{"id":13,"name":"Ιατροδικαστική"},{"id":14,"name":"Καρδιολογία"},{"id":15,"name":"Κυτταρολογία"},{"id":16,"name":"Μαιευτική Γυναικολογία"},{"id":11,"name":"Μικροβιολογία"},{"id":17,"name":"Νευρολογία"},{"id":18,"name":"Νευροχειρουργική"},{"id":19,"name":"Νεφρολογία"},{"id":20,"name":"Ορθοπαιδική"},{"id":21,"name":"Ουρολογία"},{"id":22,"name":"Οφθαλμολογία"},{"id":23,"name":"Παθολογία"},{"id":24,"name":"Παθολογική Ανατομική"},{"id":25,"name":"Παθολογική Ογκολογία"},{"id":26,"name":"Παιδιατρική"},{"id":27,"name":"Παιδοψυχιατρική"},{"id":28,"name":"Πλαστική Χειρουργική"},{"id":29,"name":"Πνευμονολογία - Φυματιολογία"},{"id":30,"name":"Πυρηνική Ιατρική"},{"id":31,"name":"Ρευματολογία"},{"id":39,"name":"Στοματική & Γναθοπροσωπική Χειρουργική"},{"id":32,"name":"Φυσική Ιατρική και Αποκατάσταση"},{"id":33,"name":"Χειρουργική"},{"id":36,"name":"Χειρουργική Β΄"},{"id":34,"name":"Χειρουργική Θώρακος"},{"id":35,"name":"Χειρουργική Παίδων"},{"id":37,"name":"Ψυχιατρική"},{"id":38,"name":"ΩΡΛ"}]
除了一个例外,一切正常。城市与专业的关系。我在回复中没有城市或专业数据

下面是我的实现

我的persistence.xml是:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="2.1">

    <persistence-unit name="PersistenceUnit">
        <!--<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>-->
        <class>gr.histopath.platform.model.TransferObjects.BodyPart</class>
        <class>gr.histopath.platform.model.TransferObjects.City</class>
        <class>gr.histopath.platform.model.TransferObjects.Clinic</class>
        <class>gr.histopath.platform.model.TransferObjects.Doctor</class>
        <class>gr.histopath.platform.model.TransferObjects.Incident</class>
        <class>gr.histopath.platform.model.TransferObjects.Patient</class>
<class>gr.histopath.platform.model.TransferObjects.SigningDoctor</class>        <class>gr.histopath.platform.model.TransferObjects.Specialty</class>
<class>gr.histopath.platform.model.TransferObjects.User</class>

        <properties>
            <!--<property name="hibernate.hbm2ddl.auto" value="create"/>-->
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/histopath.gr?useSSL=false&amp;useLegacyDatetimeCode=false&amp;serverTimezone=Europe/Athens"/>
            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
            <property name="hibernate.connection.username" value="histopathUser"/>
            <!--<property name="hibernate.connection.username" value="root"/>-->
            <property name="hibernate.connection.password" value="h1s+0p@+h"/>
            <!--<property name="hibernate.connection.password" value="Malak1es"/>-->
            <property name="hibernate.archive.autodetection" value="class"/>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.format_sql" value="true"/>
            <property name="hbm2ddl.auto" value="update"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
            <property name="hibernate.connection.provider_class" value="org.hibernate.c3p0.internal.C3P0ConnectionProvider"/>
            <property name="hibernate.connection.CharSet" value="utf8"/>
            <property name="hibernate.connection.characterEncoding" value="utf8"/>
            <property name="hibernate.connection.useUnicode" value="true"/>
            <property name="connection.pool_size" value="1"/>

            <!--<property name="hibernate.search.default.directory_provider" value="filesystem"/>-->
            <!-- hibernate c3p0 connection pooling configuration  -->
            <property name="hibernate.c3p0.acquire_increment" value="1"/>
            <property name="hibernate.c3p0.idle_test_period" value="60"/> <!-- seconds -->
            <property name="hibernate.c3p0.min_size" value="5"/>
            <property name="hibernate.c3p0.max_size" value="20"/>
            <property name="hibernate.c3p0.max_statements" value="50"/>
            <property name="hibernate.c3p0.timeout" value="0"/> <!-- seconds -->
            <property name="hibernate.c3p0.acquireRetryAttempts" value="1"/>
            <property name="hibernate.c3p0.acquireRetryDelay" value="250"/>

        </properties>
    </persistence-unit>
</persistence>

gr.HistorPath.platform.model.TransferObjects.BodyPart
gr.HistorPath.platform.model.TransferObjects.City
gr.HistorPath.platform.model.TransferObjects.Clinic
gr.HistorPath.platform.model.TransferObjects.Doctor
gr.HistorPath.platform.model.TransferObjects.Incident
gr.HistorPath.platform.model.TransferObjects.Patient
gr.HistorPath.platform.model.TransferObjects.Signing医生gr.HistorPath.platform.model.TransferObjects.Speciality
gr.HistorPath.platform.model.TransferObjects.User
传输对象为:

City.java

package gr.histopath.platform.model.TransferObjects;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;

@Entity
public class City {
    private int id;
    private String name;
    private Collection<Doctor> doctors;
    private Collection<Patient> patients;

    @Id
    @Column(name = "id")
    public int getId() {
        return id;
    }

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

    @Basic
    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        City city = (City) o;
        return id == city.id &&
                Objects.equals(name, city.name);
    }

    @Override
    public int hashCode() {

        return Objects.hash(id, name);
    }

    @OneToMany(mappedBy = "city")
    @JsonIgnore
    public Collection<Doctor> getDoctors() {
        return doctors;
    }

    public void setDoctors(Collection<Doctor> doctorsById) {
        this.doctors = doctorsById;
    }

    @OneToMany(mappedBy = "city")
    @JsonIgnore
    public Collection<Patient> getPatients() {
        return patients;
    }

    public void setPatients(Collection<Patient> patientsById) {
        this.patients = patientsById;
    }
}
package gr.historpath.platform.model.TransferObjects;
导入com.fasterxml.jackson.annotation.JsonIgnore;
导入javax.persistence.*;
导入java.util.Collection;
导入java.util.Objects;
@实体
公营城市{
私有int-id;
私有字符串名称;
私人收藏医生;
私人收集病人;
@身份证
@列(name=“id”)
公共int getId(){
返回id;
}
公共无效集合id(内部id){
this.id=id;
}
@基本的
@列(name=“name”)
公共字符串getName(){
返回名称;
}
公共void集合名(字符串名){
this.name=名称;
}
@凌驾
公共布尔等于(对象o){
如果(this==o)返回true;
如果(o==null | | getClass()!=o.getClass())返回false;
城市=(城市)o;
返回id==city.id&&
Objects.equals(name,city.name);
}
@凌驾
公共int hashCode(){
返回Objects.hash(id,name);
}
@OneToMany(mappedBy=“城市”)
@杰索尼奥雷
公共图书馆{
返回医生;
}
公共医生(收集医生BYID){
this.doctors=doctorsById;
}
@OneToMany(mappedBy=“城市”)
@杰索尼奥雷
公众收集病人(){
返回病人;
}
公共无效设置患者(收集患者BYID){
this.patients=patientsById;
}
}
java博士

package gr.histopath.platform.model.TransferObjects;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;

@Entity
public class Doctor {
    private int id;
    private String email;
    private String fatherName;
    private String firstName;
    private String lastName;
    private String telephone;
    private City city;
    private Specialty specialty;
    private Collection<Incident> incidents;

    @Id
    @Column(name = "id")
    public int getId() {
        return id;
    }

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

    @Basic
    @Column(name = "email")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Basic
    @Column(name = "fatherName")
    public String getFatherName() {
        return fatherName;
    }

    public void setFatherName(String fatherName) {
        this.fatherName = fatherName;
    }

    @Basic
    @Column(name = "firstName")
    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    @Basic
    @Column(name = "lastName")
    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    @Basic
    @Column(name = "telephone")
    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Doctor doctor = (Doctor) o;
        return id == doctor.id &&
                Objects.equals(email, doctor.email) &&
                Objects.equals(fatherName, doctor.fatherName) &&
                Objects.equals(firstName, doctor.firstName) &&
                Objects.equals(lastName, doctor.lastName) &&
                Objects.equals(telephone, doctor.telephone);
    }

    @Override
    public int hashCode() {

        return Objects.hash(id, email, fatherName, firstName, lastName, telephone, city, specialty);
    }

    @ManyToOne
    @JoinColumn(name = "city_id", referencedColumnName = "id")
    @JsonIgnore
    public City getCity() {
        return city;
    }

    public void setCity(City cityByCityId) {
        this.city = cityByCityId;
    }

    @ManyToOne
    @JoinColumn(name = "specialty_id", referencedColumnName = "id")
    @JsonIgnore
    public Specialty getSpecialty() {
        return specialty;
    }

    public void setSpecialty(Specialty specialtyBySpecialtyId) {
        this.specialty = specialtyBySpecialtyId;
    }

    @OneToMany(mappedBy = "doctor")
    @JsonIgnore
    public Collection<Incident> getIncidents() {
        return incidents;
    }

    public void setIncidents(Collection<Incident> incidentsById) {
        this.incidents = incidentsById;
    }
}
package gr.historpath.platform.model.TransferObjects;
导入com.fasterxml.jackson.annotation.JsonIgnore;
导入javax.persistence.*;
导入java.util.Collection;
导入java.util.Objects;
@实体
公立医生{
私有int-id;
私人字符串电子邮件;
私有字符串父名称;
私有字符串名;
私有字符串lastName;
专用串电话;
私人城市;
私立专业;
私人收藏事件;
@身份证
@列(name=“id”)
公共int getId(){
返回id;
}
公共无效集合id(内部id){
this.id=id;
}
@基本的
@列(name=“email”)
公共字符串getEmail(){
回复邮件;
}
公用电子邮件(字符串电子邮件){
this.email=电子邮件;
}
@基本的
@列(name=“fatherName”)
公共字符串getFatherName(){
返回父名;
}
public void setFatherName(字符串fatherName){
this.fatherName=父亲姓名;
}
@基本的
@列(name=“firstName”)
公共字符串getFirstName(){
返回名字;
}
public void setFirstName(字符串firstName){
this.firstName=firstName;
}
@基本的
@列(name=“lastName”)
公共字符串getLastName(){
返回姓氏;
}
public void setLastName(字符串lastName){
this.lastName=lastName;
}
@基本的
@列(name=“电话”)
公共字符串getTelephone(){
回电;
}
公用电话(串电话){
这个电话;
}
@凌驾
公共布尔等于(对象o){
如果(this==o)返回true;
如果(o==null | | getClass()!=o.getClass())返回false;
医生=(医生)o;
返回id==doctor.id&&
Objects.equals(电子邮件、医生电子邮件)&&
Objects.equals(父名、医生、父名)&&
Objects.equals(firstName,doctor.firstName)&&
Objects.equals(lastName,doctor.lastName)&&
对象。相等(电话、医生、电话);
}
@凌驾
公共int hashCode(){
返回Objects.hash(id、电子邮件、父亲姓名、姓氏、电话、城市、专业);
}
@许多酮
@JoinColumn(name=“city\u id”,referencedColumnName=“id”)
@杰索尼奥雷
公共城市{
回归城市;
}
公共空间集合城市(cityByCityId){
this.city=cityByCityId;
}
@许多酮
@JoinColumn(name=“speciality\u id”,referencedColumnName=“id”)
@杰索尼奥雷
公共专业{
回归专业;
}
公共无效集合特殊性(特殊性特殊性特殊性ID){
this.special=specialtyBySpecialtyId;
}
@OneToMany(mappedBy=“医生”)
@杰索尼奥雷
package gr.histopath.platform.model.TransferObjects;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.sql.Date;
import java.util.Collection;
import java.util.Objects;

@Entity
public class Patient {
    private int id;
    private Date birthday;
    private String email;
    private String fatherName;
    private String firstName;
    private String lastName;
    private String telephone;
    private Boolean sex;
    private Collection<Incident> incidents;
    private City city;

    @Id
    @Column(name = "id")
    public int getId() {
        return id;
    }

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

    @Basic
    @Column(name = "birthday")
    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    @Basic
    @Column(name = "email")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Basic
    @Column(name = "fatherName")
    public String getFatherName() {
        return fatherName;
    }

    public void setFatherName(String fatherName) {
        this.fatherName = fatherName;
    }

    @Basic
    @Column(name = "firstName")
    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    @Basic
    @Column(name = "lastName")
    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    @Basic
    @Column(name = "telephone")
    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    @Basic
    @Column(name = "sex")
    public Boolean getSex() {
        return sex;
    }

    public void setSex(Boolean sex) {
        this.sex = sex;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Patient patient = (Patient) o;
        return id == patient.id &&
                Objects.equals(birthday, patient.birthday) &&
                Objects.equals(email, patient.email) &&
                Objects.equals(fatherName, patient.fatherName) &&
                Objects.equals(firstName, patient.firstName) &&
                Objects.equals(lastName, patient.lastName) &&
                Objects.equals(telephone, patient.telephone) &&
                Objects.equals(sex, patient.sex) &&
                Objects.equals(incidents, patient.incidents) &&
                Objects.equals(city, patient.city);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, birthday, email, fatherName, firstName, lastName, telephone, sex, incidents, city);
    }

    @OneToMany(mappedBy = "patient")
    @JsonIgnore
    public Collection<Incident> getIncidents() {
        return incidents;
    }

    public void setIncidents(Collection<Incident> incidentsById) {
        this.incidents = incidentsById;
    }

    @ManyToOne
    @JsonIgnore
    @JoinColumn(name = "city_id", referencedColumnName = "id")
    public City getCity() {
        return city;
    }

    public void setCity(City cityByCityId) {
        this.city = cityByCityId;
    }
}
package gr.histopath.platform.model.TransferObjects;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;

@Entity
public class Specialty {
    private int id;
    private String name;
    private Collection<Doctor> doctors;

    @Id
    @Column(name = "id")
    public int getId() {
        return id;
    }

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

    @Basic
    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Specialty specialty = (Specialty) o;
        return id == specialty.id &&
                Objects.equals(name, specialty.name);
    }

    @Override
    public int hashCode() {

        return Objects.hash(id, name);
    }

    @OneToMany(mappedBy = "specialty")
    @JsonIgnore
    public Collection<Doctor> getDoctors() {
        return doctors;
    }

    public void setDoctors(Collection<Doctor> doctorsById) {
        this.doctors = doctorsById;
    }
}