2

I'm running EclipseLink on WLS 10.3.5.

I'm trying to use @NamedNativeQuery annotation, but all the SQL I try causes an "Internal Exception: java.sql.SQLException: SQL string is not Query" exception.

Even a simple SELECT * FROM TABLE causes that error where TABLE is the table that the containing Entity is mapped to.

The annotation is:

@NamedNativeQuery(name = AnnouncementDeliveryLog.FIND_NORMALIZED_RECIPIENTS_FOR_ANNOUNCEMENT, query =  "SELECT * FROM ANNOUNCEMENT_DELIVERY_LOG", resultClass = AnnouncementDeliveryLog.class)

The query is being executed with:

em.createNativeQuery(AnnouncementDeliveryLog.FIND_NORMALIZED_RECIPIENTS_FOR_ANNOUNCEMENT).getResultList();

I can't find a good way to get more useful information from the system so any information is appreciated.

retrodev
  • 2,323
  • 6
  • 24
  • 48

1 Answers1

2

Wrong method is in use. Method createNativeQuery takes native SQL string as an argument. In given code argument seems to be name of the native query. Method createNamedQuery should be used, it takes name of the native query as an argument.

Mikko Maunu
  • 41,366
  • 10
  • 132
  • 135