setParameterList doesn't work when using AttributeConverter

Description

I've a mapped Hibernate entity which one of its property is an enum that I created using the AttributeConverter interface.

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

@Converter(autoApply=true)
public class BankInvestmentStateConverter implements
AttributeConverter<BankInvestmentState, Character> {

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 ....
}
}
Entity:

@Entity
@Table(name = "user_transaction_bank")
public class UserTransactionBank implements Serializable {
..
..
@Column(name = "state")
@Convert(converter = BankInvestmentStateConverter.class)
private BankInvestmentState state;
..
..
}
Hibernate Query:

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();
Exception:

Cause:

java.lang.ClassCastException: java.lang.Character cannot be cast to com.shareddata.helper.BankInvestmentStateConverter$BankInvestmentState
Message:

javax.persistence.PersistenceException: Error attempting to apply AttributeConverter

Environment

PostgreSQL 9.4, Hibernate 4.3.11.Final

Activity

Show:
Gail Badner
March 4, 2016, 2:50 AM

, Hibernate ORM 4.x is no longer being maintained. Is this still an issue in 5.0.8.Final?

Assignee

Unassigned

Reporter

Oren Shvalb

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure