Skip to main content

em.createNativeQuery

2 replies [Last post]
stvconsultants
Offline
Joined: 2006-03-06

We have an existing ORACLE database with an existing password hashing function stored in a wrapped package.

I thought I would be able to call this function with a simple:

query = em.createNativeQuery("SELECT authentication_package.hashpassword(:password) FROM DUAL", String.class);
query.setParameter("password", password);
String hashedPass = (String)query.getSingleResult();

But instead I'm getting:

Exception [TOPLINK-6007] (Oracle TopLink Essentials - 2006.3 (Build 060327)): oracle.toplink.essentials.exceptions.QueryException
Exception Description: Missing descriptor for [class java.lang.String].
Query: ReadAllQuery(java.lang.String)

Which makes me suspect I may be doing something wrong, or else something is broken... any pointers

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
chris_delahunt
Offline
Joined: 2005-07-06

Hello,

You are using the wrong api. createNativeQuery(sql, class) is used for returning entities instead of specifying a ResultSetMapping.

Try just using
em.createNativeQuery("SELECT authentication_package.hashpassword(:password) FROM DUAL");

Best Regards,
Chris

stvconsultants
Offline
Joined: 2006-03-06

Thanks, yep as I suspected, I was just being a right thick eejit!

-Stephen.