Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use custom UserType in when #1286

martinsefcik opened this issue Mar 28, 2015 · 0 comments

Unable to use custom UserType in when #1286

martinsefcik opened this issue Mar 28, 2015 · 0 comments


Copy link

@martinsefcik martinsefcik commented Mar 28, 2015

I'm not able to use custom UserType in when statement in 3.6.0+. The following exception is always thrown.

Exception in thread "main" java.lang.IllegalArgumentException: Unsupported constant Approved

It works fine with 3.5.1.

sample query:

QRequest r = QRequest.request;
JPAQuery q = new JPAQuery(em);
q.orderBy(r.status.when(new Approved()).then(0).otherwise(1).asc());

status field is defined as:

@Type(type = "")
private RequestStatus status;

StatusType is custom UserType which stores java object to database as string

public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
        if (value == null) {
            st.setNull(index, StringType.INSTANCE.sqlType());
        } else {
            st.setString(index, value.getClass().getSimpleName());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.