Hi! I am a new Hibernate user and I am getting a problem while loading an object from my DB. I always get a "proxy" error. Insertion works properly. Where could the problem come from?
Hibernate version: 3.1.3
Mapping documents:
Code:
<hibernate-mapping package="test">
<class
name="User"
table="user"
>
<meta attribute="sync-DAO">false</meta>
<id
name="Id"
type="integer"
column="id"
>
<generator class="identity"/>
</id>
<property
name="Nom"
column="nom"
type="string"
not-null="true"
length="255"
/>
<property
name="Prenom"
column="prenom"
type="string"
not-null="true"
length="255"
/>
<property
name="Age"
column="age"
type="integer"
not-null="true"
length="11"
/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
User contact = (User) session.load(User.class, new Integer(1));
contact.setPrenom("Matthias");
session.save(contact);
tx.commit();
HibernateUtil.closeSession();
Full stack trace of any exception that occurs:
Quote:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" 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:862)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:781)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:774)
at Test.main(Test.java:11)
Name and version of the database you are using:
MySQL