persistence@glassfish.java.net

Re: FW: query returning null data

From: christopher delahunt <christopher.delahunt_at_oracle.com>
Date: Mon, 25 Jan 2010 09:01:12 -0500

Hello Eve,

This example is wrong and should get an NPE on customers.getCusid(). I
think you mixed up customer and customers in the parameter and the
return variable.

Best Regards,
Chris

Eve Pokua wrote:
>
>
> ------------------------------------------------------------------------
> From: gorgeous65_at_msn.com
> To: users_at_glassfish.dev.java.net
> Date: Fri, 22 Jan 2010 00:23:49 +0000
> Subject: query returning null data
>
>
> Hello everyone,
>
> I'm trying to use the following query to return data but I'm
> sure if I'm on the right track -
>
> public Customerent custLogin(Customerent customer)throws
> ShoppingException{
> Customerent customers= null;
>
> try{
> Query qt
> = em.createQuery("select c from
> Customerent c where c.cusid=?");
> qt.setParameter(1, customers.getCusid());
> return (Customerent)qt.getSingleResult();
> }catch (Exception e) {
> logger.error("There was an error getting
> the customer login details. exception: " + e);
> return customer;
>
> }
>
> }
>
> I'm not getting the results I want.
>
> Thanks
>
> eve
>
> ------------------------------------------------------------------------
> Do you have a story that started on Hotmail? Tell us now
> <http://clk.atdmt.com/UKM/go/195013117/direct/01/>
> ------------------------------------------------------------------------
> Not got a Hotmail account? Sign-up now - Free
> <http://clk.atdmt.com/UKM/go/197222280/direct/01/>