Menu

java.lang.NullPointerException

Help
Anonymous
2003-11-14
2003-11-18
  • Anonymous

    Anonymous - 2003-11-14

    Hi,
    i've just installed Hibernator 0.9.6 (version with lib) and i encounter this error when i try to connect to my database.
    I'm using Eclipse 2.1.
    I've dont a little project with one class :
    package xnet;
    public class Box
    {
        private String cd_box;
        private String txt_quotefield;
        private String cd_box_link;
       
        public Box()
        {
        }
       
        /**
         * @return
         */
        public String getCd_box()
        {
            return cd_box;
        }

        /**
         * @param string
         */
        public void setCd_box(String string)
        {
            cd_box = string;
        }
        /**
         * @return
         */
        public String getCd_box_link()
        {
            return cd_box_link;
        }

        /**
         * @return
         */
        public String getTxt_quotefield()
        {
            return txt_quotefield;
        }

        /**
         * @param string
         */
        public void setCd_box_link(String string)
        {
            cd_box_link = string;
        }

        /**
         * @param string
         */
        public void setTxt_quotefield(String string)
        {
            txt_quotefield = string;
        }

    }

    This is the Box.hbm.xml generated by Hibernator :
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
       "-//Hibernate/Hibernate Mapping DTD//EN"
       "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

    <hibernate-mapping>
        <class name="xnet.Box" table="box">
            <property name="cd_box"/>
            <property name="cd_box_link"/>
            <property name="txt_quotefield"/>
        </class>

    </hibernate-mapping>

    And this is the error while trying to map to my database (i'm usin Oracle 8i)

    java.lang.NullPointerException
        at net.sf.hibernate.mapping.PersistentClass.createPrimaryKey(PersistentClass.java:176)
        at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:292)
        at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
        at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
        at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:155)
        at net.sf.hibernator.HibernateConnection.createConnection(HibernateConnection.java:168)
        at net.sf.hibernator.views.ConnectionView$8.run(ConnectionView.java:199)
        at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
    rethrown as net.sf.hibernate.MappingException
        at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:159)
        at net.sf.hibernator.HibernateConnection.createConnection(HibernateConnection.java:168)
        at net.sf.hibernator.views.ConnectionView$8.run(ConnectionView.java:199)
        at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
    Caused by: java.lang.NullPointerException
        at net.sf.hibernate.mapping.PersistentClass.createPrimaryKey(PersistentClass.java:176)
        at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:292)
        at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
        at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
        at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:155)
        ... 3 more

    Is there something missing in my installation ?
    Thank you for your help

    Sincerely

     
    • Anonymous

      Anonymous - 2003-11-18

      same problem here :(

      using oracle9i, eclipse 2.1.2

       
    • Daniel Bradby

      Daniel Bradby - 2003-11-18

      I can see how the stack trace is coming out of Hibernate from a method called to do with primary key.

      java.lang.NullPointerException
      at net.sf.hibernate.mapping.PersistentClass.createPrimaryKey(PersistentClass.java:176)

      I suspect you need to add an id mapping element underneath you class element.

      Is this the same for you Christoph?

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.