昨天下了hibernate in action,看到Page35时,做那个Message message =  (Message) session.load(Message.class,new Long(1));时,发现异常:

1Exception in thread "main" java.lang.NullPointerException
2 at org.hibernate.tuple.AbstractTuplizer.createProxy(AbstractTuplizer.java:249
)
3 at org.hibernate.persister.entity.BasicEntityPersister.createProxy(BasicEntityPersister.java:2831
)
4 at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:218
)
5 at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:163
)
6 at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79
)
7 at org.hibernate.impl.SessionImpl.load(SessionImpl.java:603
)
8 at org.hibernate.impl.SessionImpl.load(SessionImpl.java:596
)
9 at hello.Main.main(Main.java:33)

      在网上搜了好久,在http://forums.hibernate.org/search.php?search_author=subzero&sid=b935adbea2589cce78e5b34b96615a1b找到了答案,在Message.hbm.xml里的<hibernate-mapping> 改成<hibernate-mapping  default-lazy="false">,就ok了。