-->
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: hib2ddl + annotations: NullPointerException
PostPosted: Mon Jun 18, 2007 1:00 pm 
Newbie

Joined: Mon Jun 18, 2007 11:25 am
Posts: 3
Location: London
Hi guys,

I'm trying to generate ddl from my annotated pojos, and somewhere I've got the mapping-annotations wrong (I assume), but instead of getting a nice message telling me that something doesn't make sense I'm getting a NullPointerException from somewhere in the hibernate stack. Any help would be appreciated.

I'm using the hib tools from a maven plug-in embedded in Idea, but I get the same problem in Ant, so it doesn't appear to be a maven or Idea problem.

The stack-trace starts like this:

java.lang.NullPointerException
at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:382)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039)
at org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration.getConfiguration(AbstractComponentConfiguration.java:38)
at org.codehaus.mojo.hibernate3.exporter.Hbm2DDLExporterMojo.doExecute(Hbm2DDLExporterMojo.java:87)
at org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:139)

and then degenerates into more environment specific stuff:

My dependencies (cut from my POM) are:

<artifactId>hibernate</artifactId>
<version>3.2.4.sp1</version>
<artifactId>hibernate-annotations</artifactId>
<version>3.3.0.ga</version>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.3.0.ga</version>
<artifactId>hibernate-tools</artifactId>
<version>3.2.0.beta9a</version>

My annotated pojos look a bit like this:

@Entity
public class Security {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
long id;

@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private SecurityIdentifier identifier;

@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private Country country;

@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private Currency currency;
private BigDecimal issuePrice;

@Temporal(TemporalType.DATE)
private Date dated;

@Temporal(TemporalType.DATE)
private Date firstCouponDate;
private Long couponRefixFreq;

@Temporal(TemporalType.DATE)
private Date nextRefixDate;

@Temporal(TemporalType.DATE)
etc...
}

@Entity
public class SecurityIdentifier extends BbgStaticData {
etc.
}

@MappedSuperclass
public abstract class BbgStaticData {
@Id
private int code;
}

All of the relationships are to BbgStaticData implementations.


The ant script (again, from my POM), is:

<tasks>
<echo message="Generating DDL (from maven)..."/>
<property name="dir.config" location="src/main/config"/>
<property file="${dir.config}/db.properties"/>
<property name="file.hibernate.cfg" value="${dir.config}/hibernate.cfg.xml"/>

<echo message="Using hibernate cfg: ${file.hibernate.config}"/>

<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="maven.test.classpath"/>

<hibernatetool destdir="src/main/sql">
<classpath>
<path location="target/classes"/>
</classpath>

<annotationconfiguration configurationfile="src/main/config//hibernate.cfg.xml"/>

<hbm2ddl export="false" drop="true" create="true" console="false"
outputfilename="schema.sql" format="true" haltonerror="true"
delimiter=";"/>

</hibernatetool>

</tasks>

The first couple of lines from my database.properties file are:

hibernate.dialect=org.hibernate.dialect.SybaseDialect
driver.class=com.sybase.jdbc3.jdbc.SybDrive

my hibernate.cfg.xml contains similar information (identical, except that it's xml).


TIA:

Bryan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2007 3:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
this is a problem of AnnotationConfiguration

It's in the jira somewhere....can't remember which #

_________________
Max
Don't forget to rate


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.