Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have two classes that there is a relationship @ OneToMany (Pay and Split) the code below:

@Entity
@Table(name="pagamento")
public class Pagamento implements Serializable { //Class Pay

@Id 
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="idpagamento")
private int id;
...
@ManyToOne()
@JoinColumn(name="idconta")
private Divida coddivida;

and below class Split

@Entity
@Table(name="divida")
public class Divida implements Serializable{

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "idconta")
private int id;
...
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER,                   mappedBy="coddivida",        targetEntity = Pagamento.class)
private List<Pagamento> pagamento;

And I search through the data code below:

 public List<Divida> getDividas(){
    return getCleanListOfObjects(Divida.class,"from Divida divida");
}

And I'm trying to display in a datatable is as below:

<p:dataTable id="paneluser" value="#{dividaFaces.listofDivida}" var="divida" selection="#{dividaFaces.selectedDivida}"
                     rowKey="#{divida.id}" selectionMode="sigle" emptyMessage="Não existe Dívida" paginator="true" rows="10">
            <f:facet name="header">
                Panel de Dívidas Cadastradas
            </f:facet>
            <p:column headerText="Descricão">
                #{divida.descricao}
            </p:column>
            <p:column id="pagar" headerText="Tela de Pagamento">
                <p:commandButton value="Pagar">
                    <p:ajax oncomplete="pagetela.show()" update="telapgamento"/>
                </p:commandButton>
            </p:column>
            <f:facet name="footer">
                Financé v#{sistema.VERSION}
            </f:facet>
        </p:dataTable>

But it is giving the error below:

Hibernate: 
 /* 
from
Divida divida */ select
    divida0_.idconta as idconta0_,
    divida0_.datadeinicio as datadein2_0_,
    divida0_.descricaodespesa as descrica3_0_,
    divida0_.empresa as empresa0_,
    divida0_.exercicio as exercicio0_,
    divida0_.observacao as observacao0_,
    divida0_.operacaobancaria as operacao7_0_,
    divida0_.parcela as parcela0_,
    divida0_.tipolancamento as tipolanc9_0_,
    divida0_.vencimento as vencimento0_ 
from
    divida divida0_
Lista de Dividas: []
Hibernate: 
 /* 
from
Divida divida */ select
    divida0_.idconta as idconta0_,
    divida0_.datadeinicio as datadein2_0_,
    divida0_.descricaodespesa as descrica3_0_,
    divida0_.empresa as empresa0_,
    divida0_.exercicio as exercicio0_,
    divida0_.observacao as observacao0_,
    divida0_.operacaobancaria as operacao7_0_,
    divida0_.parcela as parcela0_,
    divida0_.tipolancamento as tipolanc9_0_,
    divida0_.vencimento as vencimento0_ 
    from
    divida divida0_
    Mar 26, 2013 8:34:31 PM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
    SEVERE: Error Rendering View[/menu/principal.xhtml]
    java.lang.ClassCastException: br.com.finance.model.Divida cannot be cast to java.util.List
at    org.primefaces.component.datatable.DataTable.findSelectedRowKeys(DataTable.java:977)
at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:624)
at org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:234)
at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:196)
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:82)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:881)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:851)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:439)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

Can anyone help me?

share|improve this question
    
Please update your question in order to show an SSCCE of your managed bean. Looks like the problem is in selection="#{dividaFaces.selectedDivida}". – Luiggi Mendoza Mar 27 '13 at 2:06
up vote 0 down vote accepted

You are using selectionMode="sigle". Please notice the missing 'n' in single. The exception you are encoutering here has nothing to do with Hibernate.

share|improve this answer
    
This looks more like a typo while writing the question. – Luiggi Mendoza Mar 27 '13 at 2:04
    
This is what I thought at first time, but then, when examining the question, I am pretty sure, this is the issue, unless 'listofDivida' isn't itself a list. – Laabidi Raissi Mar 27 '13 at 8:08
    
That's why I've asked for more code. – Luiggi Mendoza Mar 27 '13 at 12:37
    
Thanks Every body with code like this: <!-- language-all: lang-html --> <p:dataTable id="paneluser" value="#{dividaFaces.listofDivida}" var="divida" selection="#{dividaFaces.selectedDivida}" emptyMessage="Não existe Dívida" paginator="true" rows="10"> it´s works. – MiguelCPJava Mar 27 '13 at 18:51
    
@MiguelCPJava sorry to say, but this answer didn't helped you at all. – Luiggi Mendoza Mar 27 '13 at 21:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.