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 on getReturnedDomainClass for parametrized types [DATAJPA-45] #480

Closed
spring-projects-issues opened this issue Mar 30, 2011 · 1 comment
Assignees
Labels
in: core Issues in core support type: bug A general bug

Comments

@spring-projects-issues
Copy link

Andres March opened DATAJPA-45 and commented

ClassCastException on getReturnedDomainClass for parametrized types.

The query:

 @NamedQuery(name = "ContentFlag.getNewFlagCountByReasonForTitleId", query = "select new map ( c.reason as reason, count(*) as numFlags ) "
                + "from ContentFlag c where c.content.title.id = ?1"
                + " and (c.dateFlagSet > c.content.statistics.dateFlagCleared or c.content.statistics.dateFlagCleared is null) "
                + "group by c.reason")

The method:

public abstract java.util.List com.qualcomm.qis.plaza.repo.ContentFlagRepository.getNewFlagCountByReasonForTitleId(java.lang.Long)

The actual return type:

java.util.List<java.util.Map<java.lang.String, java.lang.Object>>

The line where the exception is thrown:

return (Class<?>) ((ParameterizedType) type)
                    .getActualTypeArguments()[0];

The exception:

Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
	at org.springframework.data.repository.util.ClassUtils.getReturnedDomainClass(ClassUtils.java:63)
	at org.springframework.data.repository.query.QueryMethod.getDomainClass(QueryMethod.java:107)
	at org.springframework.data.jpa.repository.query.JpaQueryMethod.getNamedQueryName(JpaQueryMethod.java:126)
	at org.springframework.data.jpa.repository.query.NamedQuery.lookupFrom(NamedQuery.java:71)
	at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:132)
	at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:73)
	at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.<init>(RepositoryFactorySupport.java:259)
	at org.springframework.data.repository.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:143)
	at org.springframework.data.repository.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:107)
	at org.springframework.data.repository.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:36)
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
	... 36 more


Referenced from: commits spring-projects/spring-data-commons@680a74c

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

Should be fixed with the latest Spring Data Commons release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core support type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants