-->
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.  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: need help: Empty DDL file
PostPosted: Sat Nov 12, 2005 8:49 pm 
Newbie

Joined: Sat Nov 05, 2005 8:59 pm
Posts: 16
hi all,
I use HibernateTools-3.1.0.N200511111411 to generate DDL for EJB3 Annotated classes, but i encounter a problem: the generated DDL file is empty.

Here is my build.xml. I copied all jars of org.hibernate.eclipse_3.1.0.N200511111411/lib to my own lib directory and added my lib directory to class path.

Code:
<?xml version="1.0" ?>
<project default="main">

    <property name="my lib" value="E:/Eigene Dateien/DA/my lib" />
    <property name="project dir" value="/Dokumente und Einstellungen/Xinhua/Desktop/eclipse/workspace/one2one" />

   <target name="main" >
    </target>
    <target name="init">
    </target>
   
<path id="hibernate-tools">
    <fileset dir="${my lib}/DDL">
      <include name="**/*.jar" />
    </fileset>
</path>

   <taskdef
        name="hibernatetool"
        classname="org.hibernate.tool.ant.HibernateToolTask" >
      <classpath refid="hibernate-tools" />   
   </taskdef>
   

     <hibernatetool destdir="${project dir}">
       <classpath>
         <path location="${project dir}/bin"/>
       </classpath>
       <annotationconfiguration configurationfile="${project dir}/src/META-INF/hibernate.cfg.xml" />
       <hbm2ddl outputfilename="test.sql" />
     </hibernatetool>
   
   
</project>


Here is my Hiberante.cfg.xml

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory name="context">
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
      <mapping package="example"/>
      <mapping class ="example.Customer"/>
      <mapping class ="example.CustomerCard"/>
    </session-factory>
</hibernate-configuration>


After runing tool, the generated DDL is empty. Is there something wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 12, 2005 9:19 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
use -debug in ant to get a better idea about what is going on.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 13, 2005 5:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
this should just work. The normal error is that users forget to put the classes in the hibernate.cfg.xml, but you have done that.

It would be very interesting if you could provide the full testcase for
this example of yours that does not work.
A full testcase will be the .java, the cfg.xml and the build.xml + the output of ant -debug.

And put it all on a jira case.

Thanks.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 13, 2005 12:05 pm 
Newbie

Joined: Sat Nov 05, 2005 8:59 pm
Posts: 16
I putted them in Jira
http://opensource2.atlassian.com/projects/hibernate/browse/HBX-477

In ant -debug i found some suspicious informations among lots of "finding" and "loaded":

Code:
Couldn't load ResourceStream for META-INF/services/javax.xml.parsers.SAXParserFactory
Couldn't load ResourceStream for META-INF/services/javax.xml.parsers.SAXParserFactory

.....

Class java.util.ConcurrentModificationException loaded from parent loader (parentFirst)
Class java.util.NoSuchElementException loaded from parent loader (parentFirst)
Couldn't load ResourceStream for import.sql
Couldn't load ResourceStream for import.sql
Couldn't load ResourceStream for import.sql
Couldn't load ResourceStream for import.sql
Finding class org.hibernate.connection.ConnectionProviderFactory
Loaded from E:\Eigene Dateien\DA\my lib\DDL\hibernate3.jar org/hibernate/connection/ConnectionProviderFactory.class


Is that the reason of the problem?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 12:16 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
maybe the jira wasn't necessary ... put hibernatetool inside the task element ;)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 12:21 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
dennisbyrne wrote:
maybe the jira wasn't necessary ... put hibernatetool inside the task element ;)


he meant the target element


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 2:15 am 
Newbie

Joined: Sat Nov 05, 2005 8:59 pm
Posts: 16
Man! you are right :D


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 2:25 am 
Newbie

Joined: Sat Nov 05, 2005 8:59 pm
Posts: 16
Code:
<target name="hibernatetool">
      <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask">
         <classpath refid="hibernate-tools" />
      </taskdef>
      <hibernatetool destdir="${project dir}">
         <classpath>
            <path location="${project dir}/bin" />
         </classpath>
         <annotationconfiguration configurationfile="${project dir}/src/META-INF/hibernate.cfg.xml" />
         <hbm2ddl outputfilename="test.sql" />
      </hibernatetool>
   </target>


It works. This problem is a storm in a teacup. Sorry :))


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 2:27 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Did you just verify that if you put the <hibernatetool> into a <target name="blah"> it works for you, and otherwise not ?

what version of ant are you using ? Ant 1.6 allows out-of-target execution.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 2:36 am 
Newbie

Joined: Sat Nov 05, 2005 8:59 pm
Posts: 16
Sorry, i am wrong. it does not work :( the ddl was generated by my manual codes. :(((

I am using eclipse 3.1.1 with ant 1.6.5


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 4:13 pm 
Newbie

Joined: Sat Nov 05, 2005 8:59 pm
Posts: 16
Hi,i find the reason. It is my configuration fault.


Code:
[hibernatetool] ERROR - schema export unsuccessful
[hibernatetool] java.lang.UnsupportedOperationException: The user must supply a JDBC connection
[hibernatetool] at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:30)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.getConnection(SchemaExport.java:467)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:183)


i did not give hibernate.connection.url information in hibernate.cfg.xml.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 4:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes as noted in the jira ;)

so you do know it will both generate the sql file AND export it to the database

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 5:02 pm 
Newbie

Joined: Sat Nov 05, 2005 8:59 pm
Posts: 16
Yes, i have learned a lot from this problem. thank all the people here for the help and patience in dealing with my newbie question.:D


Top
 Profile  
 
 Post subject: empty ddl only when export="true"
PostPosted: Wed Dec 14, 2005 3:32 pm 
Newbie

Joined: Sat Nov 20, 2004 2:26 pm
Posts: 5
I'm having trouble using the annotationsconfiguration and hbm2ddl in ant as well. The relevant target is below. If I put export="no" then the ddl prints to the console as expected and saves to my output file. If I start the database and put export="yes", however, the target succeeds, but does nothing. The database is not changed, and neither the console nor the outputfile receives anything.

The database log does print the following each time I run schemaexport with export="yes":

[db.log]:
[java] [Server@a62fc3]: [Thread[HSQLDB Server @a62fc3,6,main]]: handleConnection(Socket[addr=/127.0.0.1,port=1030,localport=9001]) entered
[java] [Server@a62fc3]: [Thread[HSQLDB Server @a62fc3,6,main]]: handleConnection() exited
[java] [Server@a62fc3]: [Thread[HSQLDB Server @a62fc3,6,main]]: handleConnection(Socket[addr=/127.0.0.1,port=1031,localport=9001]) entered
[java] [Server@a62fc3]: [Thread[HSQLDB Server @a62fc3,6,main]]: handleConnection() exited



[build.xml]:
...
Code:
<target name="schemaexport" depends="compile"
     description="Generates the database schema.">
  <taskdef name="hibernatetool"
      classname="org.hibernate.tool.ant.HibernateToolTask">
    <classpath>
      <path refid="hibernate.tools.classpath" />
      <path refid="run.classpath" />
    </classpath>
  </taskdef>
       
  <hibernatetool>
    <classpath>
      <path location="${build.classes.dir}" />
      <path refid="run.classpath" />
    </classpath>
    <annotationconfiguration
    configurationfile="${build.classes.dir}/resources/hibernate.cfg.xml" />
    <hbm2ddl destdir="${build.dir}/WEB-INF/conf"
        outputfilename="sandbox.ddl"
        export="no" console="yes" create="yes" drop="yes"
        delimiter=";" />
  </hibernatetool>
</target>


Any thoughts?
Thanks,
-J


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 14, 2005 4:08 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
If your posting (or a question you are referring to) was not answered by anybody, the possible reasons are:

- http://www.hibernate.org/ForumMailingli ... AskForHelp
- You did not submit enough information
- Nobody knows the answer or has the free time to answer

What you can do now:

- Do the things listed in After Posting
- Add missing and/or more information
- Consider commercial support for guaranteed expert response times

This is a high-traffic forum run by volunteers with hundreds of postings made every day. The community works because people try to help others in their free time. Nobody is paid for this service or has to pay.

You should not expect a timely response and you should not rely on a public community forum for critical cases.

All community members should respect the rules of this forum and treat others like they would prefer to be treated.

_________________
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.  [ 19 posts ]  Go to page 1, 2  Next

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.