-->
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.  [ 9 posts ] 
Author Message
 Post subject: hbm2ddl using annotations
PostPosted: Sun Jul 30, 2006 7:30 am 
Newbie

Joined: Sat Jul 29, 2006 5:05 pm
Posts: 3
Can anyone help me in using hbm2ddl using annotations?
Is there any xml elements that I need to use with hibernate.cfg.xml ?
Or, if there is any good documentation that you can point to, that would be fine.
Thx in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 30, 2006 9:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
tools.hibernate.org its in the docs. Look for annotationconfiguraiton and/or ejb3configuration.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 30, 2006 4:09 pm 
Newbie

Joined: Sat Jul 29, 2006 5:05 pm
Posts: 3
max wrote:
tools.hibernate.org its in the docs. Look for annotationconfiguraiton and/or ejb3configuration.


This is of no use. I am trying to generate the SQL code using the annotated POJO's and hibernate.cfg.xml. Can someone show me a concrete example how to do this?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 30, 2006 5:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
did you even read the docs ?!

Code:
<hibernatetool destdir="${build.dir}/generated">
<annotationconfiguration configurationfile="hibernate.cfg.xml"/>
<hbm2ddl export="false" outputfilename="sql.ddl"/>
</hibernatetool>

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 30, 2006 5:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
..and you list classes in hibernate.cfg.xml on the form <mapping class="sdfsdf"/>

note, ejb3configuraiton is also an option...but i guess that is also not any help to you.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 30, 2006 9:21 pm 
Newbie

Joined: Fri Jul 14, 2006 10:52 am
Posts: 16
Oops, wrong thread, sorry.


Top
 Profile  
 
 Post subject: Hbm2dll with ejbConfiguration
PostPosted: Mon Jul 31, 2006 11:55 am 
Newbie

Joined: Thu Sep 22, 2005 4:32 am
Posts: 7
Location: Italy
I have a similar problem. So far, I've reached the point that hbm2dll seems to read my classes, but then stops with:

Code:
[hibernatetool] Executing Hibernate Tool with a EJB3 Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] Problems in creating a Ejb3Configuration. Have you remembered to add it to the classpath ?
[hibernatetool] java.lang.reflect.InvocationTargetException
[hibernatetool] javax.persistence.PersistenceException: No name provided and several persistence units found

BUILD FAILED
build.xml:89: Problems in creating a Ejb3Configuration. Have you remembered to add it to the classpath ?


My build.xml reads:

Code:
    <hibernatetool destdir="${build.dir}">
      <ejb3configuration />
      <classpath>
        <!-- it is in this classpath you put your classes dir,
          and/or ejb3 persistence compliant jar -->
        <path location="${build.prod.dir}" />
      </classpath>
      <!-- list exporters here -->
      <hbm2ddl export="false" drop="true" create="true"
        outputfilename="schema-export.sql" delimiter=";" format="true" />
    </hibernatetool>


While my persistence.xml reads:
Code:
  <persistence-unit name="regintel" transaction-type="RESOURCE_LOCAL">
    <class>com.vst.model.Parametri</class>
    <class>com.vst.model.Dato</class>
    <class>com.vst.model.Localita</class>
    <properties>
      <property name="hibernate.dialect"
        value="org.hibernate.dialect.OracleDialect" />
      <property name="hibernate.connection.driver_class"
        value="oracle.jdbc.OracleDriver" />
      <property name="hibernate.connection.username" value="interel232" />
      <property name="hibernate.connection.password" value="pword" />
      <property name="hibernate.connection.url"
        value="jdbc:oracle:thin:@localhost:1521:orcl" />
      <property name="hibernate.max_fetch_depth" value="3" />
    </properties>
  </persistence-unit>


The error seems to hint that the name of the persistence unit needs to be specified, but it's not clear to me where...

Thanks in advance,

Michele


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 31, 2006 12:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it seems like you have more than one persistence.xml listed in your classpath ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 31, 2006 3:37 pm 
Newbie

Joined: Thu Sep 22, 2005 4:32 am
Posts: 7
Location: Italy
That was a hint in the right direction... got it!
Thanks!


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