The easier option is to allow those annotations to be defined at the
package level.
Not sure of the usefulness of allowing definition of them via CDI, but
that's just my personal taste.
On Thu, Apr 27, 2017 at 12:47 PM Guillermo González de Agüero <
z06.guillermo_at_gmail.com> wrote:
> Hi,
>
> Following the CDI integration movement we've seen on other specs, I to
> propose to expand the places where @NamedQueries, @NamedNativeQueries and
> @NamedStoreProcedureQueries (and possibily some more I'm missing), to
> aknowledge every discovered type by CDI [1], instead of just @Entity
> annotated classes.
>
> In most cases, entities are the best place to place that annotations, but:
> - Stored procedures often don't return an entity, and usually they are not
> even related with an entity, but just perform some business work and return
> a result code. In that case, the bussines component would be a better place
> to put it.
> - Both JPQL and native queries can return non entity objects. JPQL through
> the NEW operator, and native queries through @ConstructorResultset.
> Annotating the resulting DTO would be more natural that annotating an
> entity that has nothing to do with it.
>
> Of course, we can define them in XML [2], but I find it cumbersome and IDE
> support is not very good (at least on NetBeans).
>
> Allowing to use those annotations on CDI managed beans wouldn't be enough,
> as the DTOs probably won't be managed beans anyway. But searching for the
> annotations on every CDI discovered type [1] would account for the majority
> of use cases and provide a unified experience.
>
> What do you all think?
>
>
>
> Regards,
>
> Guillermo González de Agüero
>
>
> [1]
> http://docs.oracle.com/javaee/7/api/javax/enterprise/inject/spi/ProcessAnnotatedType.html
> [2]
> http://arjan-tijms.omnifaces.org/2010/09/where-to-put-named-queries-in-jpa.html
>