Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/391.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 Datatable显示两个具有关系的不同实体表,需要从数据库表中获取另一列值_Java_Hibernate_Spring Mvc_Primefaces_Dao - Fatal编程技术网

Java Datatable显示两个具有关系的不同实体表,需要从数据库表中获取另一列值

Java Datatable显示两个具有关系的不同实体表,需要从数据库表中获取另一列值,java,hibernate,spring-mvc,primefaces,dao,Java,Hibernate,Spring Mvc,Primefaces,Dao,我需要从UI jsf的单个dataTable中的LangDef实体类中获取Language Name的列值。请尽快通知我 <p:dataTable id="dataTable" emptyMessage="#{res.NO_RECORDS_FOUND}" var="lab" value="#{labelsMB.listData}" editable="true" editMode="cell" paginator="true" rows="10" paginatorTemplate="

我需要从UI jsf的单个dataTable中的LangDef实体类中获取Language Name的列值。请尽快通知我

<p:dataTable id="dataTable" emptyMessage="#{res.NO_RECORDS_FOUND}" var="lab" value="#{labelsMB.listData}" editable="true" editMode="cell" paginator="true" rows="10" paginatorTemplate="  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"   rowsPerPageTemplate="5,10,15"> 
<p:column headerText="#{res.CAPTION_DET}" sortBy="#{lab.captionDet}" filterBy="#{lab.captionDet}" filterMatchMode="contains" filterStyle="width: 360px;">
                                        <p:cellEditor>
                                            <f:facet name="output">
                                                <h:outputText value="#{lab.captionDet}" />
                                            </f:facet>
                                            <f:facet name="input">
                                                <h:inputText value="#{lab.captionDet}" style="width:96%"/>
                                            </f:facet>
                                        </p:cellEditor>
                                    </p:column>
                                    <p:column headerText="#{res.LABEL_NO}" sortBy="#{lab.iasLabelsPK.labelNo}" filterBy="#{lab.iasLabelsPK.labelNo}">
                                        <p:outputLabel value="#{lab.iasLabelsPK.labelNo}" />
                                    </p:column>
                                    <p:column headerText="#{res.LANGUAGE_NO}" sortBy="#{lab.iasLabelsPK.langNo}" filterBy="#{lab.iasLabelsPK.langNo}" width="100">
                                        <p:outputLabel value="#{lab.iasLabelsPK.langNo}" />
                                    </p:column>
                                    <p:column headerText="#{res.LANGUAGE_NAME}" sortBy="#{lab.???????}" filterBy="#{lab.?????}" width="130">
                                        <p:outputLabel value="#{lab...?????}" />
                                    </p:column>
 </p:dataTable>

我需要从UI jsf的单个dataTable中的LangDef entity类中获取Language Name的列值。请尽快告诉我您只需要在代码中进行如下更改

<p:dataTable id="dataTable" emptyMessage="#{res.NO_RECORDS_FOUND}" var="lab" value="#{labelsMB.listData}" editable="true" editMode="cell" paginator="true" rows="10" paginatorTemplate="  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"   rowsPerPageTemplate="5,10,15"> 
<p:column headerText="#{res.CAPTION_DET}" sortBy="#{lab.captionDet}" filterBy="#{lab.captionDet}" filterMatchMode="contains" filterStyle="width: 360px;">
                                        <p:cellEditor>
                                            <f:facet name="output">
                                                <h:outputText value="#{lab.captionDet}" />
                                            </f:facet>
                                            <f:facet name="input">
                                                <h:inputText value="#{lab.captionDet}" style="width:96%"/>
                                            </f:facet>
                                        </p:cellEditor>
                                    </p:column>
                                    <p:column headerText="#{res.LABEL_NO}" sortBy="#{lab.iasLabelsPK.labelNo}" filterBy="#{lab.iasLabelsPK.labelNo}">
                                        <p:outputLabel value="#{lab.iasLabelsPK.labelNo}" />
                                    </p:column>
                                    <p:column headerText="#{res.LANGUAGE_NO}" sortBy="#{lab.iasLabelsPK.langNo}" filterBy="#{lab.iasLabelsPK.langNo}" width="100">
                                        <p:outputLabel value="#{lab.iasLabelsPK.langNo}" />
                                    </p:column>
                                    <p:column headerText="#{res.LANGUAGE_NAME}" sortBy="#{lab.???????}" filterBy="#{lab.?????}" width="130">
                                        <p:outputLabel value="#{lab...?????}" />
                                    </p:column>
 </p:dataTable>
在xhtml中:

<p:column headerText="#{res.LANGUAGE_NAME}" sortBy="#{lab.langDef.langName}"    filterBy="#{lab.langDef.langName}" width="130">
              <p:outputLabel value="#{lab.langDef.langName}" />
</p:column>
希望对你有帮助

编辑:

public interface ILabelsDAO extends CrudRepository<IasLabels, IasLabelsPK>{        
    @Query List<IasLabels> findAll(); 
}
您需要在spring配置文件中添加以下内容

@Autowired
SessionFactory sessionFactory;

@Override
public void addInterceptors(InterceptorRegistry registry) {
            registry.addWebRequestInterceptor(openSessionInViewInterceptor());
}

@Bean
public OpenSessionInViewInterceptor openSessionInViewInterceptor(){
        OpenSessionInViewInterceptor openSessionInterceptor = new OpenSessionInViewInterceptor();
        openSessionInterceptor.setSessionFactory(sessionFactory);
        return openSessionInterceptor;
}

您只需要对代码进行如下更改

在xhtml中:

<p:column headerText="#{res.LANGUAGE_NAME}" sortBy="#{lab.langDef.langName}"    filterBy="#{lab.langDef.langName}" width="130">
              <p:outputLabel value="#{lab.langDef.langName}" />
</p:column>
希望对你有帮助

编辑:

public interface ILabelsDAO extends CrudRepository<IasLabels, IasLabelsPK>{        
    @Query List<IasLabels> findAll(); 
}
您需要在spring配置文件中添加以下内容

@Autowired
SessionFactory sessionFactory;

@Override
public void addInterceptors(InterceptorRegistry registry) {
            registry.addWebRequestInterceptor(openSessionInViewInterceptor());
}

@Bean
public OpenSessionInViewInterceptor openSessionInViewInterceptor(){
        OpenSessionInViewInterceptor openSessionInterceptor = new OpenSessionInViewInterceptor();
        openSessionInterceptor.setSessionFactory(sessionFactory);
        return openSessionInterceptor;
}


您需要将列表与LangDef类结合起来,对吗?是的…在LangDef实体类中,我只需要数据库的LANG_NAME列值IasLabels实体与LangDef实体之间的任何关系?具有列名称LANG_NO的IasLabels和具有相同列名称LANG_noismsgspk实体是LANG_NO,并且LangDef实体primerykey是LANG_NO您需要将列表与LangDef类合并,对吗?是的…在LangDef实体类中,我只需要数据库的LANG_NAME列值IasLabels实体与LangDef实体之间的任何关系?具有列名称LANG_NO的IasLabels和具有相同列名称LANG_noismsgspk实体为LANG_NO,且LangDef实体primerykey为LANG_NO此错误正在获取正在运行我的项目…HTTP状态500-无法提取结果集;SQL[n/a];嵌套异常为org.hibernate.exception.sqlgrammareexception:无法提取结果您需要从代码中删除fetch=FetchType.LAZY并在执行后重试…获取相同的异常无法提取结果集;SQL[n/a];嵌套异常为org.hibernate.exception.SQLGrammarException:无法提取结果我认为您忘记在配置中写入此行,请查看我的编辑应答,因为它对我有效,我在单个表中获得了结果此错误正在运行我的项目…HTTP状态500-无法提取结果集;SQL[n/a];嵌套异常为org.hibernate.exception.sqlgrammareexception:无法提取结果您需要从代码中删除fetch=FetchType.LAZY并在执行后重试…获取相同的异常无法提取结果集;SQL[n/a];嵌套异常为org.hibernate.exception.sqlgrammareexception:无法提取结果我认为您忘记在配置中写入这一行,请查看我的编辑答案,因为它对我有效,我在单个表中得到了结果