| Hi All
 I have two simple data objects, an object ( Subscriber ) has a reference to another object ( Test ) . It is a many to one relationship i.e many Subscribers can belong to One Test class. With this, I have the following
 Hibernate Mapping definition.
 
 <class name="Test" table="test">
 <id name="id">
 <generator class="native"/>
 </id>
 <property name="name" type="string"/>
 </class>
 
 <class name="Subscriber" table="subscriber">
 <id name="id">
 <generator class="native"/>
 </id>
 <many-to-one name="test" class="Test" column="test_id" not-null="true"/>
 <property name="phonenumber" type="string"/>
 </class>
 
 
 These are the two Classes: ( Note: removed the getters and setters for brevity )
 
 public class Subscriber {
 private Long id;
 private String phoneNumber;
 private Test test;
 }
 
 public class Test {
 private Long id;
 private String name;
 }
 
 
 I get an error , when I try to create a SessionFactory in this piece of code
 
 static {
 try {
 sessionFactory = new Configuration().configure().buildSessionFactory();
 } catch (HibernateException ex) {
 throw new RuntimeException("Exception building SessionFactory: " + ex.getMessage(), ex);
 }  catch (Exception e) {
 
 
 The error is Exception is:  java.lang.ExceptionInInitializerError
 
 I have other mappings that work except this, and I do have the hibernate.cfg.xml and the *.hbm.xml file in the classpath.
 
 Can someone shed some light on this.
 
 Thanks
 
 
 |