Hibernate in Netbeans 6.1 , tutorial, does not work

View: New views
3 Messages — Rating Filter:   Alert me  

Hibernate in Netbeans 6.1 , tutorial, does not work

by mlotfi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am trying to learn Hibernate, I found this tutorial :
http://www.netbeans.org/kb/61/web/hibernate-vwp.html

I follwed all the steps, but at the end I got a table with a message : no items

in the Page1.jsp I got a Null pointer exception :

 public void prerender() {
        try {
        if (dropDown1.getSelected() == null ) {
            // NullPointer Exception in this line :
            Option firstPerson = getSessionBean1().getPersonOptions()[0];
            getSessionBean1().setSelectedPersonId((Integer)firstPerson.getValue());
        }
    } catch (Exception ex) {
        log("Error Description", ex);
        error(ex.getMessage());
    }

    }

Thanks, your help is appreciated.

Re: Hibernate in Netbeans 6.1 , tutorial, does not work

by Tomasz Zakrzewski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

getPresonOptions must return null.
Are you sure that you have added buildPersonOptions() to init() method
and buildPersonOptions() correctly initialize personOptions ?

Try to use debugger to find problem.



> Hi,
>
> I am trying to learn Hibernate, I found this tutorial :
> http://www.netbeans.org/kb/61/web/hibernate-vwp.html
>
> I follwed all the steps, but at the end I got a table with a message : no
> items
>
> in the Page1.jsp I got a Null pointer exception :
>
>  public void prerender() {
>         try {
>         if (dropDown1.getSelected() == null ) {
>             // NullPointer Exception in this line :
>             Option firstPerson = getSessionBean1().getPersonOptions()[0];
>            
> getSessionBean1().setSelectedPersonId((Integer)firstPerson.getValue());
>         }
>     } catch (Exception ex) {
>         log("Error Description", ex);
>         error(ex.getMessage());
>     }
>
>     }
>
> Thanks, your help is appreciated.


Re: Hibernate in Netbeans 6.1 , tutorial, does not work

by mlotfi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Tomasz,

Yes I have added buildPersonOptions() to init() method
and buildPersonOptions() correctly initialize personOptions , I did exactly what in the tutorial I added bold code with cut and paste, I was trying to debug buildPersonOptions()  method, but the jsp page start wthout going there.

Note, I am using mysql database, I can see the connection in the database explorer, execute queries.

Thanks

Tomasz Zakrzewski wrote:
Hi,

getPresonOptions must return null.
Are you sure that you have added buildPersonOptions() to init() method
and buildPersonOptions() correctly initialize personOptions ?

Try to use debugger to find problem.



> Hi,
>
> I am trying to learn Hibernate, I found this tutorial :
> http://www.netbeans.org/kb/61/web/hibernate-vwp.html
>
> I follwed all the steps, but at the end I got a table with a message : no
> items
>
> in the Page1.jsp I got a Null pointer exception :
>
>  public void prerender() {
>         try {
>         if (dropDown1.getSelected() == null ) {
>             // NullPointer Exception in this line :
>             Option firstPerson = getSessionBean1().getPersonOptions()[0];
>            
> getSessionBean1().setSelectedPersonId((Integer)firstPerson.getValue());
>         }
>     } catch (Exception ex) {
>         log("Error Description", ex);
>         error(ex.getMessage());
>     }
>
>     }
>
> Thanks, your help is appreciated.
LightInTheBox - Buy quality products at wholesale price