Hi akm Given it is stated like that in the documentation, I guess we have a bug here. The code doesn't call the EM with a result class so there's no mapping happening. As a workaround, you might specify a @NamedNativeQuery where you can add a result class and then reference it in the @Query annotation.
Hope that helps, Thomas On Thu, Aug 6, 2015 at 9:52 PM, akm <ameh...@ford.com> wrote: > I have a simple native query in my repository > > @Query(value = "select * from COUNTRY c where c. COUNTRY_C = ?1", isNative > = > true) > public abstract List<Country> findCountryByCode(String countryCode); > > I execute it by the following line – > List<Country> countryList = > this.countryRepository.findCountryByCode(this.countryCode); > > I see the right query being executed – > [EL Finest]: query: Execute query DataReadQuery(sql="select * from COUNTRY > c > where c. COUNTRY_C = ?1") > > And my list contains my expected results, but the problem is when I try to > do any operation on the entity I get an error > Caused by: java.lang.ClassCastException: [Ljava.lang.Object; incompatible > with com.domain.Country > > In this test I am just trying to get the names from the country > for (Country country : countryList) { > country.getName(); > } > > Casting the result does not work either. > Shouldn’t the returned objects be of the Entity type? > > What am I doing wrong? How do I get the Entity type result? > Thanks. > > > > > -- > View this message in context: > http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/Return-type-of-Repository-native-query-tp4661333.html > Sent from the Apache DeltaSpike Incubator Discussions mailing list archive > at Nabble.com. >