Hibernate Attribute Converter doesn't work for setParameterList
<p>I've a mapped Hibernate entity which one of its property is an enum that I created using the AttributeConverter interface.</p>

<p>It works fine for most cases, but if I use it inside a "IN" clause it doesn't work, Here is the code:</p>

<pre><code>@Converter(autoApply=true)
public class BankInvestmentStateConverter implements       
AttributeConverter&lt;BankInvestmentState, Character&gt; {

    public enum BankInvestmentState {
        ON_GOING('O'),      
        WITHDRAW('W'),
        ENDED('E'), 
        COLLECTED('C');
       ...
       .....
    }

    @Override
    public Character convertToDatabaseColumn(BankInvestmentState state) {
        ....
    }

    @Override
    public BankInvestmentState convertToEntityAttribute(Character dbData) {
        return ....
    }
}
</code></pre>

<p>Entity:</p>

<pre><code>@Entity
@Table(name = "user_transaction_bank")
public class UserTransactionBank implements Serializable {
    ..
    ..
    @Column(name = "state")
    @Convert(converter = BankInvestmentStateConverter.class)
    private BankInvestmentState state;
    ..
    ..
}
</code></pre>

<p>Hibernate Query:</p>

<pre><code>UserTransactionBank transaction = (UserTransactionBank)session.createQuery(
    "FROM UserTransactionBank WHERE userId=:user_id AND state IN (:statesList)")
    .setLong("user_id", user_id)
    .setParameterList("statesList", new Character[] { BankInvestmentState.ON_GOING.toChar(), BankInvestmentState.ENDED.toChar() })
    .uniqueResult();
</code></pre>

<p>Exception:</p>

<p>Cause:</p>

<pre><code>java.lang.ClassCastException: java.lang.Character cannot be cast to com.shareddata.helper.BankInvestmentStateConverter$BankInvestmentState
</code></pre>

<p>Message:</p>

<pre><code>javax.persistence.PersistenceException: Error attempting to apply AttributeConverter
</code></pre>

<p>Any ideas why this happen?
by the way, if instead of using .setParameterList(...), I simply hardcoded the IN(..) it works fine.</p>

<p>Thank you!</p>