-->
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: Not able to create session for many to one mapping
PostPosted: Tue Mar 09, 2004 4:05 pm 
Newbie

Joined: Thu Mar 04, 2004 7:20 pm
Posts: 1
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 4:38 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
can you give all stacktrace?


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.