-->
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.  [ 3 posts ] 
Author Message
 Post subject: hbm2ddl/SchemaExport NullPointerException for export=false
PostPosted: Wed Aug 09, 2006 11:53 pm 
Newbie

Joined: Wed Jan 28, 2004 4:19 am
Posts: 4
hbm2ddl doesn't seem to allow only creating the SQL file with export=false, it has to have export="true" and update the database, or it will throw an NPE (stack trace below).

Looking at the code (SchemaExport line 311) it is because statement.getWarnings() is accessed but statement is null when export=false. The check for warnings should be inside the "if ( export ) ".

The workaround is to set export="true", obviously, but it would be nice if this was fixed. I searched JIRA but couldn't find any matching issue.

Hibernate version: hibernate-3.2.0.cr3

Ant task code
<target name="schema-recreate" depends="compile">
<hibernatetool destdir="">
<configuration propertyfile="${src.dir}/project.properties">
<fileset dir="${src.dir}">
<include name="model.hbm.xml"/>
</fileset>
</configuration>
<!-- NB doesn't work with export=false, get NullPointerException in SchemaExport -->
<hbm2ddl drop="true" create="true" export="false" update="false" outputfilename="../SQL/model.sql"/>
</hibernatetool>
</target>


Full stack trace of any exception that occurs:
Location: org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:202) Message:
schema export unsuccessful
Throwable:
java.lang.NullPointerException
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:311)
at org.hibernate.tool.hbm2ddl.SchemaExport.drop(SchemaExport.java:284)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:186)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:133)
at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:55)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:160)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)

Name and version of the database you are using: Oracle 10gr2


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 2:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
this should already be fixed.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 2:43 am 
Newbie

Joined: Wed Jan 28, 2004 4:19 am
Posts: 4
Ah OK, it does look fixed in the latest trunk version of SchemaExport.java. Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.