Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
hibernate 3.1
Mapping documents:
<class name="Location">
<id name="id" unsaved-value="0" >
<generator class="hilo">
<param name="max_lo">0</param>
</generator>
</id>
<property name="no" />
<property name="ad" length="50"/>
<property name="description" length="255"/>
<many-to-one name="parent" class="Location" />
<list name="children" >
<key column="parent"/>
<index column="no" type="int"/>
<one-to-many class="Location" />
</list>
<list name="categories" lazy="true" >
<key column="category"/>
<index column="no" type="int"/>
<many-to-many class="Location"/>
</list>
</class>
Code between sessionFactory.openSession() and session.close():
Location mother= new Location("mother location");
sess.save(mother);
Location child = new Location("child location");
child.setParent(mother);
sess.save(child);
Full stack trace of any exception that occurs:
3640 [main] INFO org.hibernate.tool.hbm2ddl.SchemaUpdate - schema update complete
3687 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - cleaning up connection pool: jdbc:sybase:Tds:taciz:4100/sandbox
3687 [main] INFO org.hibernate.impl.SessionFactoryImpl - Checking 0 named queries
Exception in thread "main" org.hibernate.PropertyAccessException: exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of akkam.sky.core.Location.?
at org.hibernate.tuple.PojoEntityTuplizer.getPropertyValuesWithOptimizer(PojoEntityTuplizer.java:229)
at org.hibernate.tuple.PojoEntityTuplizer.getPropertyValuesToInsert(PojoEntityTuplizer.java:203)
at org.hibernate.persister.entity.AbstractEntityPersister.getPropertyValuesToInsert(AbstractEntityPersister.java:3303)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:244)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:114)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:513)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:509)
at akkam.sky.Main.main(Main.java:52)
Caused by: java.lang.NullPointerException
at akkam.sky.core.Location.getNo(Location.java:75)
at akkam.sky.core.Location$$BulkBeanByCGLIB$$f465456b.getPropertyValues(<generated>)
at net.sf.cglib.beans.BulkBean.getPropertyValues(BulkBean.java:48)
at org.hibernate.tuple.PojoEntityTuplizer.getPropertyValuesWithOptimizer(PojoEntityTuplizer.java:226)
... 14 more
Java Result: 1
BUILD SUCCESSFUL (total time: 5 seconds)
Name and version of the database you are using:
sybase any where
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: