-->
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: Error creating an OneToMany Schema from classes to database
PostPosted: Fri Aug 19, 2005 10:05 pm 
Newbie

Joined: Thu Aug 18, 2005 12:24 pm
Posts: 11
Hibernate version:

Hi, Im trying to create my database schema from my bean classes.. I made this simple test and Im getting a null pointer exception.. here's how my classes are:

CLASS BOOK ( The 'Many' side ):
...
...
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn( name="customer_fk" )
public Customer getCustomer()
{
return this.customer;
}

@Id
public java.lang.Integer getId()
{
return id;
}

...

CLASS CUSTOMER ( The 'One' Side ):


@OneToMany( cascade = CascadeType.ALL, fetch = FetchType.LAZY )
@Id
public Integer getId()
{
return this.id;
}

....

And when I try to export the schema like this:

...
try
{
cfg = new AnnotationConfiguration( );
cfg.configure( CONFIG_FILE_LOCATION );
cfg.addAnnotatedClass( Book.class );
cfg.addAnnotatedClass( Customer.class );


SchemaExport se = new SchemaExport( cfg );
se.create( true , true );

}
...

I get this exception:

Exception in thread "main" java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:396)
at java.util.Properties.setProperty(Properties.java:128)
at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1345)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:863)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:575)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:194)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:570)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:64)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:49)
at br.com.mindsatwork.libraryweb.test.SchemaBuilder.main(SchemaBuilder.java:49)

I have no Idea of what is going on... What is wrong? Any help is welcome..
thanks!!!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 21, 2005 8:07 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
And id cannot be a one to many which is a collection by nature.

_________________
Emmanuel


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.