-->
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: generate schema with jpa annotations. Help!
PostPosted: Thu Mar 29, 2007 5:10 pm 
Newbie

Joined: Tue Mar 27, 2007 5:24 am
Posts: 2
Hibernate 3 with jpa annotations, and trying to use schemaExportTask

When I try to create a schema using the SchemaExportTask I get the error

I get the error
Schema text failed: An AnnotationConfiguration instance is required to use <mapping class="nz.org.model.account.Account"/>


I have had a pretty good search around the web to no avail. I am guessing I need to declare something within my test_hibernate.cfg.xml? Surely I do not need to instantiate this class when I am generating the schema, right? I am using the persistence annotations in the Account class
(@Entity and @Id)

Ant snippet
Code:

<target name="schema-export">
      <taskdef classname="org.hibernate.tool.hbm2ddl.SchemaExportTask" classpathref="master.classpath" name="schemaexport" />
      <schemaexport drop="true" config="${test.dir}/test_hibernate.cfg.xml" output="${sql.dir}/schema.sql" quiet="false" text="false">
      </schemaexport>
   </target>



and test_hibernate.cfg.xml
Code:
<hibernate-configuration>
   <session-factory>

      <property name="connection.driver_class">
         com.mysql.jdbc.Driver
      </property>
      <property name="connection.url">
         jdbc:mysql://localhost/
      </property>
      <property name="connection.username">discomanifesto</property>
      <property name="connection.password"></property>
      <property name="dialect">
         org.hibernate.dialect.MySQLDialect
      </property>

      <!-- Mappings -->
      <!--<mapping package="com.discomanifesto.model."/>-->
      <mapping class="nz.org.mike.model.account.Account" />

   </session-factory>
</hibernate-configuration>


Help!

Thanks heaps,

Mike Casey

_________________
MSC


Top
 Profile  
 
 Post subject: Sorry, I cannot help ...
PostPosted: Thu Apr 05, 2007 4:56 pm 
Beginner
Beginner

Joined: Sun Sep 04, 2005 3:10 am
Posts: 24
Location: CH
but I want tell you that I ran into the same error, though not in the same situation.
I try to rewrite an application in JPA-Style. So it looks as if we do sth. wrong with annotations not so much like you the Schemawriting. My application worked until I started to rewrite it in JPA-manner.
It might have sth. 2do with the configuration file. Take a look at http://www.manning.com/bauer2/chapter2.pdf
Page 71

Regards, chk


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 06, 2007 3:48 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You are using the wrong Ant task. What you are using is the original Hibernate Core SchemaExport task. This task can only handle Hibernate XML mapping files, not annotations. (Hibernate Core runs on JDK 1.4)

What you want is the "HibernateTool" task that comes with Hibernate Tools: http://tools.hibernate.org/

It's also described with examples in the PDF the previous poster already mentioned, see page 65.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.