0

I work with oracle DB, in my table I have one field string datatype (value: true or false)

I have tried to transform for this field p:selectOneMenu with p:selectBooleanButton by inspired solution from Convert h:selectBooleanCheckbox value between boolean and String,

I have tried this code in my persistence layer or in myBean

@Size(max = 5)
@Column(name = "CHAMP04")
private String champ04;

    public boolean isChamp04() {
        return "true".equals(champ04);
    }

    public void setChamp04(boolean champ04) {
        this.champ04 = champ04 ? "true" : "false";
    }

I get error

javax.validation.ValidationException: HV000028: Unexpected exception during isValid call.

Caused By: java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.CharSequence.

this error be came when I go back to the p:dataTable list after save/cancel Dialogs views Edit or Create selected row.

<p:column>
  <f:facet name="header">
    <h:outputText value="#{bundle.ListTitle_champ04}" />
  </f:facet>
  <h:outputText value="#{item.champ04}" />
</p:column>

If I change declaration for the field, I get error

private boolean champ04;

javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: java.lang.Boolean

thank you in advance for your help and attention

krilas
  • 47
  • 4
  • This is a Hibernate issue not a PF issue. Do a search on how to properly map your String to a boolean. – Melloware Nov 30 '20 at 19:33
  • thank you, I have tried solutions in this post [link](https://stackoverflow.com/questions/1154833/configure-hibernate-using-jpa-to-store-y-n-for-type-boolean-instead-of-0-1) from @MarcG and Jim Tough but I ged error _No validator could be found for type: java.lang.Boolean_ – krilas Dec 01 '20 at 10:23
  • I get solution from @Dave Moten, but without JpaUtil class. – krilas Dec 01 '20 at 12:29

0 Answers0