These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Seesion.load problem !!!!!!
PostPosted: Mon Jul 31, 2006 5:45 am 
Newbie

Joined: Mon Jul 31, 2006 5:27 am
Posts: 1
I have a problem with session.load when i run:
Event anEvent = (Event) session.load(Event.class, new Long(2603));

this exception will thrown:

java.lang.NullPointerException
at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:869)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:788)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:781)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:292)
at $Proxy0.load(Unknown Source)
at events.EventManager.createAndStorePerson(EventManager.java:61)
at events.EventManager.main(EventManager.java:26)

the complete code is:
Session session = HibernateUtil.getSessionFactory().getCurrentSession();

session.beginTransaction();

Person thePerson = new Person();
thePerson.setFirstname(firstName);
thePerson.setLastname(lastName);

Event anEvent = (Event) session.load(Event.class, new Long(2603));

thePerson.getEvents().add(anEvent);

session.save(thePerson);

session.getTransaction().commit();


but, if i write code like this, it works well!!!
Session session = HibernateUtil.getSessionFactory().getCurrentSession();

session.beginTransaction();

Person thePerson = new Person();
thePerson.setFirstname(firstName);
thePerson.setLastname(lastName);

List result = session.createQuery("from Event where id = 2603").list();
Event anEvent = (Event) result.get(0);

thePerson.getEvents().add(anEvent);

session.save(thePerson);

session.getTransaction().commit();

What's the problem?????????????????
Thanks for help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 31, 2006 10:18 am 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
Two things:

1. Learn how to post a proper request for help.
2. Are you aware that this is the NHibernate forum which deals with the C# port of Hibernate and NOT the main Hibernate forum?

Cheers,
Radu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.