Olá pessoal,
Preciso de uma ajuda aqui, quando executo o método abaixo com asterisco na query ele roda, mas gostaria de deixar somente o campo que vou usar e deixando somente o campo me retorna o erro:
[ERROR ] An unhandled exception occurred which will be propagated to the container. [ERROR ] SRVE0777E: Exception thrown by application class 'org.eclipse.persistence.exceptions.QueryException.nullPrimaryKeyInBuildingObject:912' Exception [EclipseLink-6044] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.QueryException Exception Description: The primary key read from the row [ArrayRecord( => teste teste)] during the execution of the query was detected to be null. Primary keys must not contain null. Query: ReadAllQuery(referenceClass=ParteDescricao sql="
Exception Description: The primary key read from the row [ArrayRecord( => BASE MASCARILLA)] during the execution of the query was detected to be null. Primary keys must not contain null. Query: ReadAllQuery(referenceClass=ParteDescricao sql="
Alguma idéia ? Obrigado.
//*** Método de Persistência *
public List<ParteDescricao> listByLanguage( final ParteDescricao de, final String country) {
StringBuilder sb = new StringBuilder ();
sb.append("\n BEGIN");
sb.append("\n ");
sb.append("\n DECLARE @country CHAR(5); ");
sb.append("\n SET @country = ? ; ");
sb.append("\n ");
sb.append("\n SELECT top (1)
// ************** Aqui ocorre o problema ******************
sb.append("\n *
//sb.append("\n P.Language
// ********************************************************
sb.append("\n FROM TableLanguage AS P
sb.append("\n WHERE P.ID = ?
sb.append("\n AND (P.Language = @country
sb.append("\n OR SUBSTRING(P.Language,1,2) = SUBSTRING(@country,1,2)
sb.append("\n OR P.Language = 'EN-DD')
sb.append("\n ORDER BY
sb.append("\n CASE WHEN P.Language = @country THEN 1
sb.append("\n WHEN SUBSTRING(P.Language,1,2) = SUBSTRING(@country,1,2) then 2
sb.append("\n ELSE 3
sb.append("\n END;
sb.append("\n END;");
javax.persistence.Query query = this.getEntityManager().createNativeQuery(sb.toString(), PartsDescriptionDE.class);
int i = 1;
if (country != null) {
query.setParameter(i++, country);
}
if (de.getBkParteID) != null) {
query.setParameter(i++, de.getBkParteID());
}
return query.getResultList();
}