java.lang.NullPointerException

Hibernate JIRA | manoj kochhar | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Running the auction example in the eg directory. Have 3 suggested improvements and found a bug that stopped it from working: Suggested improvements: 1. BID column called datetime in the database. This is a bad name for a column. Perhaps biddatetime would be better 2. DDL that is generated has some column names in upper case and some in lower case. Suggest all upper case 3. In AuctionItem.hbm.xml the <import class="AuctionInfo"> appears to have no significance. Perhaps remove this The main issue I had: In org.hibernate.auction.Main method "public void createTestAuctions() throws Exception" I get the stack trace below because of this line: bidder2.setName( new Name("Steve", null, "Ebersole") ); The initial is null and is of type java.lang.Character. This products the following stack trace: org.hibernate.auction.User#3] [java] java.lang.NullPointerException [java] at org.hibernate.type.PrimitiveType.toString(PrimitiveType.java: ) [java] at org.hibernate.type.NullableType.nullSafeSet(NullableType.java 9) [java] at org.hibernate.type.NullableType.nullSafeSet(NullableType.java 3) [java] at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.ja :261) [java] at org.hibernate.persister.entity.AbstractEntityPersister.dehydr e(AbstractEntityPersister.java:1826) [java] at org.hibernate.persister.entity.AbstractEntityPersister.dehydr e(AbstractEntityPersister.java:1803) [java] at org.hibernate.persister.entity.AbstractEntityPersister.insert bstractEntityPersister.java:2059) [java] at org.hibernate.persister.entity.AbstractEntityPersister.insert bstractEntityPersister.java:2427) [java] at org.hibernate.action.EntityInsertAction.execute(EntityInsertA ion.java:51) [java] at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243 [java] at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.j a:227) [java] at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.j a:140) [java] at org.hibernate.event.def.AbstractFlushingEventListener.perform ecutions(AbstractFlushingEventListener.java:296) [java] at org.hibernate.event.def.DefaultFlushEventListener.onFlush(Def ltFlushEventListener.java:27) [java] at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980) [java] at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java: 3) [java] at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransact n.java:106) [java] at org.hibernate.auction.Main.createTestAuctions(Main.java:353) [java] at org.hibernate.auction.Main.main(Main.java:374) The initial that is set to null is converted to a String and not a Character causing the error. Can get around it by: 1. bidder2.setName( new Name("Steve", new Character('R'), "Ebersole") ); 2. Changing db table column auctionuser.initial to a VARCHAR2 I think the real problem appears to in the mapping of java.lang.Character if the value is null.

    Hibernate JIRA | 1 decade ago | manoj kochhar
    java.lang.NullPointerException

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.hibernate.type.PrimitiveType.toString()
    2. Hibernate
      AbstractEntityPersister.dehydre
      1. org.hibernate.type.PrimitiveType.toString(PrimitiveType.java)
      2. org.hibernate.type.NullableType.nullSafeSet(NullableType.java9)
      3. org.hibernate.type.NullableType.nullSafeSet(NullableType.java3)
      4. org.hibernate.type.ComponentType.nullSafeSet(ComponentType.ja:261)
      5. org.hibernate.persister.entity.AbstractEntityPersister.dehydre(AbstractEntityPersister.java:1826)
      6. org.hibernate.persister.entity.AbstractEntityPersister.dehydre(AbstractEntityPersister.java:1803)
      6 frames