cancel
Showing results for 
Search instead for 
Did you mean: 

Named query exception JPA

Former Member
0 Kudos

Hello

I wrote a simple named query in my entity class which is throwing me an exception.

@NamedQueries({

@NamedQuery(name="custrecords",query="SELECT c FROM CustDetails c WHERE lower(c.customerName) = :customerName"),

@NamedQuery(name="allcustrecords",query="SELECT c FROM CustDetails c")

})

Exception in defaultTrace.trc file:

The generated SQL statement is not valid for the underlying database platform (platform no. 99). For more details see attached exception. SQL statement is SELECT "C"."CUSTOMER_NO" "C_CUSTOMER_NO_customerNo","C"."CUSTOMER_NAME" "C_CUSTOMER_NAME_customerName","C"."STREET_1" "C_STREET_1_street1","C"."BUILDING_NAME" "C_BUILDING_NAME_buildingName","C"."CONTACT_NAME" "C_CONTACT_NAME_contactName","C"."POST_CODE" "C_POST_CODE_postCode","C"."CREDIT_LIMIT" "C_CREDIT_LIMIT_creditLimit","C"."COMPANY_REGN_NO" "DISPLAY_1","C"."COUNTRY" "C_COUNTRY_country","C"."VAT_REGN_NO" "C_VAT_REGN_NO_vatRegnNo" FROM "TMP_CUST_DETAILS" "C" WHERE LOWER("C"."CUSTOMER_NAME") = ?#

..............................................

.............................................

com.sap.engine.lib.injection.InjectionException: Injection on field em of instance com.centrica.scv.service.CustomerBean@1d53bb failed. Could not get a value to be injected from the factory.

I am using MAX DB.

Can some one tell me how to resolve this.

Thanks

Vidyadhar

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi, Vidyadhar:

It seems error happen in the assign variable em at runtime.

A workable code should like below.


@PersistenceContext(unitName = "xxx")
private EntityManager em;

xxxx is the value which defined in the META-INF/persistence.xml

take a look about JPA in the online help.

http://help.sap.com/saphelp_nwce711/helpdata/en/44/eba6292f446c30e10000000a114a6b/frameset.htm

BR,

Nick.