On 5/16/10 6:50 PM, Fabio Perfetti wrote:
Oh! sorry...but i resolved!! all day trying and the problem was that i
allocat the dipendenteDao in the method, but i must allocate it as an
attribute of action.
So i put in the action

private DipendenteDAO dipendenteDao = new DipendenteService();

and i resolved!!

Thanks all

Typically you want more separation. You want the DAO layer interacting directly with the database, you want the service layer doing business logic, and you want the web layer to connect the web pages with the business logic. So I wouldn't suggest having any action directly utilizing DAOs, and I wouldn't suggest that you ever make the service layer and the DAO layer synonymous, both of which you appear to be doing...

-Dale

2010/5/16 Dale Newfield <d...@newfield.org <mailto:d...@newfield.org>>

    On 5/16/10 1:13 PM, Fabio Perfetti wrote:

        Hi! I am having problems with struts 2.1.8 and the plugin for
        integrate
        hibernate.


        java.lang.NullPointerException
        at
        
it.tesina.model.DipendenteService.getByUsername(DipendenteService.java:42)


        public Dipendente getByUsername(String username){
        Dipendente dipendente = null;
        try{
        System.out.println(session);
        String queryString = "from Dipendente where USERNAME = :username";
        Query query = session.createQuery(queryString);
        System.out.println(query);
        query.setString("username", username);
        Object queryResult = query.uniqueResult();
        dipendente = (Dipendente) queryResult;
        } catch (Exception e) {
        e.printStackTrace();
        }
        return dipendente;
        }



    So which of those lines is #42?

    If I had to guess I'd say it's the session.createQuery() call if you
    aren't getting your session initialized correctly...what's the
    println show?

    -Dale




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to