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

ClassCastException when using nested MappingProjection with single Expression #295

Kwaq opened this issue Nov 28, 2012 · 1 comment


Copy link

@Kwaq Kwaq commented Nov 28, 2012

Version: 2.9.0

I'm getting this exception:

java.lang.ClassCastException: java.lang.String cannot be cast to com.example.ResultPart
    at com.example.MappingTest$
    at com.example.MappingTest$
    at com.mysema.query.types.MappingProjection.newInstance(
    at com.mysema.query.types.FactoryExpressionUtils$FactoryExpressionAdapter.newInstance(
    at com.mysema.query.jpa.hibernate.FactoryExpressionTransformer.transformTuple(
    at org.hibernate.hql.HolderInstantiator.instantiate(
    at org.hibernate.loader.hql.QueryLoader.getResultList(
    at org.hibernate.loader.Loader.listIgnoreQueryCache(
    at org.hibernate.loader.Loader.list(
    at org.hibernate.loader.hql.QueryLoader.list(
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(
    at org.hibernate.engine.query.HQLQueryPlan.performList(
    at org.hibernate.impl.SessionImpl.list(
    at org.hibernate.impl.QueryImpl.list(
    at org.hibernate.ejb.QueryImpl.getResultList(
    at com.mysema.query.jpa.impl.AbstractJPAQuery.getResultList(
    at com.mysema.query.jpa.impl.AbstractJPAQuery.list(

Executing following code

        final JPAQuery query = new JPAQuery(entityManager);

        final QSomeEntity ent = QSomeEntity.someEntity;
        final MappingProjection<ResultPart> key = new MappingProjection<ResultPart>(ResultPart.class,
            ent.firstProperty) {

            protected ResultPart map(final Tuple row) {
                return new ResultPart();

        final List<ResultObject> list = query.from(ent).list(
            new MappingProjection<ResultObject>(ResultObject.class, key) {

                protected ResultObject map(final Tuple row) {
                    final ResultPart consolidationKey = row.get(key);
                    return new ResultObject();

Changing key projection declaration to

        final MappingProjection<ResultPart> key = new MappingProjection<ResultPart>(ResultPart.class,
            ent.firstProperty, ent.secondProperty) {

            protected ResultPart map(final Tuple row) {
                return new ResultPart();


As You notice, the only difference is that in second case I pass two expressions to MappingProjection constructor.
I don't fill result objects because it is irrelevant. ResultPart is supposed to be part of the ResultObject.

timowest added a commit that referenced this issue Nov 28, 2012
Copy link

@timowest timowest commented Jan 13, 2013

Released in 3.0.0.BETA1

@timowest timowest closed this Jan 13, 2013
timowest added a commit that referenced this issue Apr 19, 2013
@timowest timowest added this to the 3.0.0 milestone Apr 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants