Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.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
Java Hibernate:返回奇怪值的多对多对象列表_Java_Hibernate_Hibernate Mapping - Fatal编程技术网

Java Hibernate:返回奇怪值的多对多对象列表

Java Hibernate:返回奇怪值的多对多对象列表,java,hibernate,hibernate-mapping,Java,Hibernate,Hibernate Mapping,我正在使用hibernate,使用多对多表访问特定实体时遇到问题。简而言之:我想从列表中获取一个实体并显示它。 这是xml <hibernate-mapping> <class name="entity.Blocohaspretexto" table="blocohaspretexto" catalog="geradoc" optimistic-lock="version">

我正在使用hibernate,使用多对多表访问特定实体时遇到问题。简而言之:我想从列表中获取一个实体并显示它。 这是xml

<hibernate-mapping>
    <class name="entity.Blocohaspretexto" table="blocohaspretexto" catalog="geradoc" optimistic-lock="version">
        <id name="id" type="java.lang.Integer">
            <column name="id" />
            <generator class="identity" />
        </id>
        <many-to-one name="bloco" class="entity.Bloco" fetch="select">
            <column name="id_fk_bloco_pre" not-null="true" />
        </many-to-one>
        <many-to-one name="pretexto" class="entity.Pretexto" fetch="select">
            <column name="id_fk_pretexto" not-null="true" />
        </many-to-one>
    </class>
</hibernate-mapping>

在银行中搜索和插入类

public class BlocoHasPretextoDAO {

    public Session session = null;
    public Transaction tx;

    public void insert(Blocohaspretexto bhp) {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();
        session.save(bhp);
        tx.commit();
        session.close();
    }

    //BUSCA BlocohasPretextos através do id de um Bloco
    public List<Blocohaspretexto> searchBlocoHasPretexto() {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();
        List<Blocohaspretexto> blocosHasPretextos = null;
        Query query = session.createQuery("FROM Blocohaspretexto");
        blocosHasPretextos = query.list();
        tx.commit();
        session.close();
        return blocosHasPretextos;
    }

}
public类blocohaspretdextoa{
公共会话=空;
公开交易;
公共空白插入(Blocohaspretexto必和必拓){
session=HibernateUtil.getSessionFactory().openSession();
tx=session.beginTransaction();
session.save(必和必拓);
tx.commit();
session.close();
}
//布斯卡·布卢科哈斯普雷特斯·阿特拉维·多伊德·布卢科酒店
公共列表搜索blocohaspretexto(){
session=HibernateUtil.getSessionFactory().openSession();
tx=session.beginTransaction();
List blocoshasprextos=null;
Query Query=session.createQuery(“来自Blocohaspretexto”);
blocosHasPretextos=query.list();
tx.commit();
session.close();
返回blocoshaspextos;
}
}
代码的一部分,我获取BlocoHasPretexto列表,并将Pretexto类型的元素的值赋给变量

public class FXMLBlocoController extends Application implements Initializable {
//codes
  @Override
    public void initialize(URL url, ResourceBundle rb) {
        List<Blocohaspretexto> bhp = blocoHasPretextoDAO.listarBlocoHasPretexto();
        Blocohaspretexto bp = bhp.get(1);
        Pretexto p = bp.getPretexto();
    }
 //codes
}
公共类FXMLBlocoController扩展应用程序实现可初始化{
//代码
@凌驾
公共void初始化(URL、ResourceBundle rb){
List bhp=blocohaspretextrado.listarblocohaspretextro();
Blocohaspretexto bp=bhp.get(1);
Pretexto p=bp.getPretexto();
}
//代码
}
我调试过了,但是值​​这个借口有:头像、静态和继承。 在继承中,它具有值​​然而,对于类借口,它们是空的