Sql Result Set Mapping with non-entity

696 Views Asked by At

Is it possible to have map a JPA 2.x sql result set mapping to a non-entity? I haven't seen any documentation for this. Currently we are using EclipseLink 2.5 and classpath scanning. I'm also interested, if there is an alternative way to define in the persistence.xml? Here is an exmaple...

package com.example.model

@SqlResultMapping(name = "nonpojoentity", class= { 
     @ConstructorResult(targetClass = MyNonEntityPojo.class, columns = {
      ...
     }) 
})
@NamedNativeQueries(values = {
   @NamedNativeQuery(name="...", query = "...", resultSetMapping = "nonpojoentity"
})
public class MyNonEntityPojo implements Serializable {
  ....
}

So unless I place @Entity on the MyNonEntityPojo class EclipseLink does not recognize it. The problem is ... It's not an entity, and if I were to do any sort of ddl generation from my code it would be incorrect. Thoughts? Has anyone else solved this problem?

0

There are 0 best solutions below