-->
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.  [ 4 posts ] 
Author Message
 Post subject: SchemaExport refusing to work
PostPosted: Tue Jan 11, 2005 10:36 am 
Beginner
Beginner

Joined: Tue Dec 28, 2004 11:30 am
Posts: 32
Hibernate version:
2.1.7
Mapping documents:
team.hbm.xml
<hibernate-mapping>
<class name="example.Team" table="teams">
<id name="id" column="team_id" type="long" unsaved-value="null">
<generator class="hilo"/>
</id>
<property name="name" column="team_name" type="string"
length="15" not-null="true"/>
<property name="city" column="city" type="string" length="15" not-null="true"/>
<set name="players" cascade="all" inverse="true" lazy="true">
<key column="team_id"/>
<one-to-many class="example.Player"/>
</set>
</class>
</hibernate-mapping>

player.hbm.xml
<hibernate-mapping>
<class name="example.Player" table="players">
<id name="id" column="player_id" type="long" unsaved-value="null">
<generator class="hilo"/>
</id>
<property name="firstName" column="first_name" type="string" length="12" not-null="true"/>
<property name="lastName" column="last_name" type="string" length="15" not-null="true"/>
<property name="draftDate" column="draft_date" type="date"/>
<property name="annualSalary" column="salary" type="float"/>
<property name="jerseyNumber" column="jersey_number" type="integer" length="2" not-null="true"/>
<many-to-one name="team" class="example.Team" column="team_id"/>
</class>
</hibernate-mapping>


Hibernate.properties
hibernate.connection.username=team
hibernate.connection.password=team
hibernate.connection.url=jdbc:mysql://localhost:3306/example?autoReconnectForPools=true
hibernate.connection.driver_class=org.gjt.mm.mysql.Driver

hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
hibernate.connection.pool_size=3 # optional, see below

hibernate.show_sql=true

So when i type on the command line

net.sf.hibernate.tool.hbm2ddl.SchemaExport /Users/greg/Desktop/tut/player.hbm.xml /Users/greg/Desktop/tut/team.hbm.xml

I get the following

Full stack trace of any exception that occurs:
log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
net.sf.hibernate.MappingException: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:179)
at net.sf.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:289)
Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:173)
... 1 more
Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at org.dom4j.io.SAXReader.read(SAXReader.java:219)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:172)
... 1 more


Name and version of the database you are using:
mysql 4.1.7

Any ideas ?
thank you


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 10:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
please read the exception.

It says your are missing a grammar - and the hbm.xml files you show don't seem to include the <!DOCTYPE hibernate-mapping .... line.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 11:12 am 
Beginner
Beginner

Joined: Tue Dec 28, 2004 11:30 am
Posts: 32
Thank you that was the problem,


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 12, 2005 9:50 am 
Beginner
Beginner

Joined: Tue Dec 28, 2004 11:30 am
Posts: 32
I have another quick question after fixing this problem when i type

java net.sf.hibernate.tool.hbm2ddl.SchemaExport --output="/Users/greg/Desktop/tut/schema.sql" /Users/greg/Desktop/tut/player.hbm.xml /Users/greg/Desktop/tut/team.hbm.xml

it runs fine and produces a schema.sql file , but the only problem is that this file is empty , Any comments on that ?

Thank you
Again


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