无法在hibernate JPA中检索大孩子

时间:2014-12-30 11:57:28

标签: java hibernate jpa

Configurationarticle type个孩子,article types可能有article types个孩子。
我正在尝试检索所有configuration及其子级(article type的所有configuration)。
我不会在这里找到父母和孩子article type 我想通过使用配置实体来检索所有授予子项。

这是我的configuration实体: -

@Entity
@Table(name = "tbl_configuration")
@XmlRootElement
public class Configuration extends BaseEntity implements Serializable
{
    private static final long                   serialVersionUID    = 1L;

    @Id
    @Basic(optional = false)
    @Column(name = "config_index")
    private Integer                             configIndex;

    @Column(name = "config_nom")
    private String                              configNom;

    @Column(name = "config_revision")
    private String                              configRevision;

    @JsonManagedReference(value="configuration-article-type")
    @OneToMany(mappedBy = "artTypPcIndexConfig", fetch = FetchType.EAGER)
    private Collection<ArticleTypeParentChild>  articleTypeParentChildCollection;

    public Configuration()
    {
    }

    public Configuration(Integer configIndex)
    {
        this.configIndex = configIndex;
    }

    public Integer getConfigIndex()
    {
        return configIndex;
    }

    public void setConfigIndex(Integer configIndex)
    {
        this.configIndex = configIndex;
    }

    public String getConfigNom()
    {
        return configNom;
    }

    public void setConfigNom(String configNom)
    {
        this.configNom = configNom;
    }

    public String getConfigRevision()
    {
        return configRevision;
    }

    public void setConfigRevision(String configRevision)
    {
        this.configRevision = configRevision;
    }



    public Collection<ArticleTypeParentChild> getArticleTypeParentChildCollection()
    {
        return articleTypeParentChildCollection;
    }

    public void setArticleTypeParentChildCollection(Collection<ArticleTypeParentChild> articleTypeParentChildCollection)
    {
        this.articleTypeParentChildCollection = articleTypeParentChildCollection;
    }

}

ArticleTypeParentChild表实体

@Entity
@Table(name = "tbl_article_type_parent_child")
@XmlRootElement
public class ArticleTypeParentChild extends BaseEntity implements Serializable
{
    private static final long   serialVersionUID    = 1L;

    @Id
    @Basic(optional = false)
    @Column(name = "art_type_pc_index")
    private Integer             artTypePcIndex;

    @JsonBackReference(value="child-article-type")
    @JoinColumn(name = "art_typ_child_index", referencedColumnName = "art_typ_index")
    @ManyToOne(fetch = FetchType.EAGER)
    private ArticleType         artTypChildIndex;

    @JsonBackReference(value="parent-article-type")
    @JoinColumn(name = "art_typ_parent_index", referencedColumnName = "art_typ_index")
    @ManyToOne(fetch = FetchType.EAGER)
    private ArticleType         artTypParentIndex;

    @JsonBackReference(value="configuration-article-type")
    @JoinColumn(name = "art_typ_pc_index_config", referencedColumnName = "config_index")
    @ManyToOne(fetch = FetchType.EAGER)
    private Configuration       artTypPcIndexConfig;

    public ArticleTypeParentChild()
    {
    }

    public ArticleTypeParentChild(Integer artTypePcIndex)
    {
        this.artTypePcIndex = artTypePcIndex;
    }

    public Integer getArtTypePcIndex()
    {
        return artTypePcIndex;
    }

    public void setArtTypePcIndex(Integer artTypePcIndex)
    {
        this.artTypePcIndex = artTypePcIndex;
    }   

    public ArticleType getArtTypChildIndex()
    {
        return artTypChildIndex;
    }

    public void setArtTypChildIndex(ArticleType artTypChildIndex)
    {
        this.artTypChildIndex = artTypChildIndex;
    }

    public ArticleType getArtTypParentIndex()
    {
        return artTypParentIndex;
    }

    public void setArtTypParentIndex(ArticleType artTypParentIndex)
    {
        this.artTypParentIndex = artTypParentIndex;
    }

    public Configuration getArtTypPcIndexConfig()
    {
        return artTypPcIndexConfig;
    }

    public void setArtTypPcIndexConfig(Configuration artTypPcIndexConfig)
    {
        this.artTypPcIndexConfig = artTypPcIndexConfig;
    }
}

ArticleType表实体: -

public class ArticleType extends BaseEntity implements Serializable
{
    private static final long                       serialVersionUID    = 1L;

    @Id
    @Basic(optional = false)
    @Column(name = "art_typ_index")
    private Integer                                 artTypIndex;

    @Basic(optional = false)
    @Column(name = "art_typ_index_designation")
    private int                                     artTypIndexDesignation;

    @Basic(optional = false)
    @Column(name = "art_typ_code")
    private String                                  artTypCode;

    @Basic(optional = false)
    @Column(name = "art_typ_code_effectivite")
    private String                                  artTypCodeEffectivite;

    @Basic(optional = false)
    @Column(name = "art_typ_numero_serie")
    private boolean                                 artTypNumeroSerie;

    @Basic(optional = false)
    @Column(name = "art_typ_version_materiel")
    private boolean                                 artTypVersionMateriel;

    @Basic(optional = false)
    @Column(name = "art_typ_version_logiciel")
    private boolean                                 artTypVersionLogiciel;

    @Column(name = "art_typ_index_description")
    private String                                  artTypIndexDescription;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "atrIndexArticleType")
    private Collection<ArticleTypeReseau>           articleTypeReseauCollection;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "atvIndexArticleType")
    private Collection<ArticleTypeVariante>         articleTypeVarianteCollection;

    @JoinColumn(name = "art_typ_index_option", referencedColumnName = "opt_art_index")
    @ManyToOne
    private OptionArticle                           artTypIndexOption;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "atpIndexArticleType")
    private Collection<ArticleTypeProjet>           articleTypeProjetCollection;

    @OneToMany(mappedBy = "atvoIndexArticleType")
    private Collection<ArticleTypeVarianteOption>   articleTypeVarianteOptionCollection;

    @JsonManagedReference(value="child-article-type")
    @OneToMany(mappedBy = "artTypChildIndex", fetch = FetchType.EAGER)
    private Collection<ArticleTypeParentChild>      articleTypeChildCollection;

    @JsonManagedReference(value="parent-article-type")
    @OneToMany(mappedBy = "artTypParentIndex", fetch = FetchType.EAGER)
    private Collection<ArticleTypeParentChild>      articleTypeParentCollection;

    @OneToMany(mappedBy = "atoIndexArtType")
    private Collection<ArticleTypeOption>           articleTypeOptionCollection;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "locIndexArticleType")
    private Collection<Localisation>                localisationCollection;

    @OneToMany(mappedBy = "atlIndexArticleType")
    private Collection<ArticleTypeLocalisation>     articleTypeLocalisationCollection;

    public ArticleType()
    {
    }

    public ArticleType(Integer artTypIndex)
    {
        this.artTypIndex = artTypIndex;
    }

    public ArticleType(Integer artTypIndex, int artTypIndexDesignation, String artTypCode, String artTypCodeEffectivite, boolean artTypNumeroSerie, boolean artTypVersionMateriel, boolean artTypVersionLogiciel)
    {
        this.artTypIndex = artTypIndex;
        this.artTypIndexDesignation = artTypIndexDesignation;
        this.artTypCode = artTypCode;
        this.artTypCodeEffectivite = artTypCodeEffectivite;
        this.artTypNumeroSerie = artTypNumeroSerie;
        this.artTypVersionMateriel = artTypVersionMateriel;
        this.artTypVersionLogiciel = artTypVersionLogiciel;
    }

    public Integer getArtTypIndex()
    {
        return artTypIndex;
    }

    public void setArtTypIndex(Integer artTypIndex)
    {
        this.artTypIndex = artTypIndex;
    }

    public int getArtTypIndexDesignation()
    {
        return artTypIndexDesignation;
    }

    public void setArtTypIndexDesignation(int artTypIndexDesignation)
    {
        this.artTypIndexDesignation = artTypIndexDesignation;
    }

    public String getArtTypCode()
    {
        return artTypCode;
    }

    public void setArtTypCode(String artTypCode)
    {
        this.artTypCode = artTypCode;
    }

    public String getArtTypCodeEffectivite()
    {
        return artTypCodeEffectivite;
    }

    public void setArtTypCodeEffectivite(String artTypCodeEffectivite)
    {
        this.artTypCodeEffectivite = artTypCodeEffectivite;
    }

    public boolean getArtTypNumeroSerie()
    {
        return artTypNumeroSerie;
    }

    public void setArtTypNumeroSerie(boolean artTypNumeroSerie)
    {
        this.artTypNumeroSerie = artTypNumeroSerie;
    }

    public boolean getArtTypVersionMateriel()
    {
        return artTypVersionMateriel;
    }

    public void setArtTypVersionMateriel(boolean artTypVersionMateriel)
    {
        this.artTypVersionMateriel = artTypVersionMateriel;
    }

    public boolean getArtTypVersionLogiciel()
    {
        return artTypVersionLogiciel;
    }

    public void setArtTypVersionLogiciel(boolean artTypVersionLogiciel)
    {
        this.artTypVersionLogiciel = artTypVersionLogiciel;
    }

    public String getArtTypIndexDescription()
    {
        return artTypIndexDescription;
    }

    public void setArtTypIndexDescription(String artTypIndexDescription)
    {
        this.artTypIndexDescription = artTypIndexDescription;
    }

    @XmlTransient
    public Collection<ArticleTypeReseau> getArticleTypeReseauCollection()
    {
        return articleTypeReseauCollection;
    }

    public void setArticleTypeReseauCollection(Collection<ArticleTypeReseau> articleTypeReseauCollection)
    {
        this.articleTypeReseauCollection = articleTypeReseauCollection;
    }

    @XmlTransient
    public Collection<ArticleTypeVariante> getArticleTypeVarianteCollection()
    {
        return articleTypeVarianteCollection;
    }

    public void setArticleTypeVarianteCollection(Collection<ArticleTypeVariante> articleTypeVarianteCollection)
    {
        this.articleTypeVarianteCollection = articleTypeVarianteCollection;
    }

    public OptionArticle getArtTypIndexOption()
    {
        return artTypIndexOption;
    }

    public void setArtTypIndexOption(OptionArticle artTypIndexOption)
    {
        this.artTypIndexOption = artTypIndexOption;
    }

    @XmlTransient
    public Collection<ArticleTypeProjet> getArticleTypeProjetCollection()
    {
        return articleTypeProjetCollection;
    }

    public void setArticleTypeProjetCollection(Collection<ArticleTypeProjet> articleTypeProjetCollection)
    {
        this.articleTypeProjetCollection = articleTypeProjetCollection;
    }

    @XmlTransient
    public Collection<ArticleTypeVarianteOption> getArticleTypeVarianteOptionCollection()
    {
        return articleTypeVarianteOptionCollection;
    }

    public void setArticleTypeVarianteOptionCollection(Collection<ArticleTypeVarianteOption> articleTypeVarianteOptionCollection)
    {
        this.articleTypeVarianteOptionCollection = articleTypeVarianteOptionCollection;
    }

//  @XmlTransient
    public Collection<ArticleTypeParentChild> getArticleTypeParentChildCollection()
    {
        return articleTypeChildCollection;
    }

    public void setArticleTypeParentChildCollection(Collection<ArticleTypeParentChild> articleTypeParentChildCollection)
    {
        this.articleTypeChildCollection = articleTypeParentChildCollection;
    }

//  @XmlTransient
    public Collection<ArticleTypeParentChild> getArticleTypeParentChildCollection1()
    {
        return articleTypeParentCollection;
    }

    public void setArticleTypeParentChildCollection1(Collection<ArticleTypeParentChild> articleTypeParentChildCollection1)
    {
        this.articleTypeParentCollection = articleTypeParentChildCollection1;
    }

    @XmlTransient
    public Collection<ArticleTypeOption> getArticleTypeOptionCollection()
    {
        return articleTypeOptionCollection;
    }

    public void setArticleTypeOptionCollection(Collection<ArticleTypeOption> articleTypeOptionCollection)
    {
        this.articleTypeOptionCollection = articleTypeOptionCollection;
    }

    @XmlTransient
    public Collection<Localisation> getLocalisationCollection()
    {
        return localisationCollection;
    }

    public void setLocalisationCollection(Collection<Localisation> localisationCollection)
    {
        this.localisationCollection = localisationCollection;
    }

    @XmlTransient
    public Collection<ArticleTypeLocalisation> getArticleTypeLocalisationCollection()
    {
        return articleTypeLocalisationCollection;
    }

    public void setArticleTypeLocalisationCollection(Collection<ArticleTypeLocalisation> articleTypeLocalisationCollection)
    {
        this.articleTypeLocalisationCollection = articleTypeLocalisationCollection;
    }
}

0 个答案:

没有答案