-->
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.  [ 8 posts ] 
Author Message
 Post subject: Correct DTD for orm.xml
PostPosted: Thu Jun 15, 2006 2:17 am 
Newbie

Joined: Mon Jan 26, 2004 4:21 pm
Posts: 10
Hi all,

I want to specify my mappings in orm.xml, instead of via annotations.

I'm using:
    hibernate 3.2.0.cr2
    hibernate-annotations 3.2.0.cr1
    hibernate-entitymanager 3.2.0.cr1

Here is my orm.xml file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
               version="1.0">


  <entity class="bar.foo.Person">
    <attributes>
      <id name="id"/>
      <basic name="firstName"/>
      <basic name="lastName"/>
    </attributes>
  </entity>
</entity-mappings>

The problem is that HB -apparently- tries to validate the file, but cannot find the DTD.
Here is the exception:
Code:
org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'entity-mappings'.
   at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
   at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
   at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
   at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
   at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1944)
   at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)
   at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:330)
   at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:779)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1794)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
   at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
   at org.dom4j.io.SAXReader.read(SAXReader.java:465)
   at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:563)


I cannot to save my life figure out the right values for xmlns, xmlns:xsi, and xsi:schemaLocation in orm.xml.

Could somebody please post a sample orm.xml that works with the latest HB?

Thank you,

Susie.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 16, 2006 12:27 pm 
Newbie

Joined: Mon Jan 26, 2004 4:21 pm
Posts: 10
Hi again,

An I the only one trying to move from annotations to the now supported orm.xml mapping file?
I checked the docs and forum, and it seems that not very many people are switching.

Thanks,

Susie.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 16, 2006 2:05 pm 
Newbie

Joined: Mon Jan 26, 2004 4:21 pm
Posts: 10
Ha, I found an example of a working orm.xml file at http://blog.hibernate.org/cgi-bin/blosx ... tojpa.html.

But now, I'm getting the following exception:

Code:

Caused by: org.hibernate.AnnotationException: Cannot override an property with <id> it does not have an @Id already
   at org.hibernate.reflection.java.EJB3OverridenAnnotationReader.getId(EJB3OverridenAnnotationReader.java:919)
   at org.hibernate.reflection.java.EJB3OverridenAnnotationReader.initAnnotations(EJB3OverridenAnnotationReader.java:347)
   at org.hibernate.reflection.java.EJB3OverridenAnnotationReader.isAnnotationPresent(EJB3OverridenAnnotationReader.java:257)
   at org.hibernate.reflection.java.JavaXAnnotatedElement.isAnnotationPresent(JavaXAnnotatedElement.java:40)
   at org.hibernate.cfg.AnnotationBinder.mustBeSkipped(AnnotationBinder.java:998)
   at org.hibernate.cfg.AnnotationBinder.addProperty(AnnotationBinder.java:978)
   at org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(AnnotationBinder.java:942)
   at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:788)
   at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:614)
   at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:353)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:265)
   at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034)
   at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1015)
   at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
   at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:751)
   at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
   at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:205)
   ... 29 more

Here is the bean I'm trying to map:
Code:
public class Person
{

  public Long id;

  public String firstName;
  public String lastName;

If I annotate the id field with '@Id @GeneratedValue' , it works.

I don't get it. The point of the mapping file is to not have annotations. Why this exception?

Thanks,

S.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 16, 2006 4:09 pm 
Newbie

Joined: Mon Jan 26, 2004 4:21 pm
Posts: 10
I found what the probelm was: I need to add metadata-complete="true" to the <entity tag:
Code:
<entity class="foo.bar.Person" metadata-complete="true">


S.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 29, 2006 5:07 am 
Newbie

Joined: Sat Jun 11, 2005 1:49 am
Posts: 3
Don't worry, you're not the only one who prefers xml over annotations :)

Code:
  <persistence-unit-metadata>
    <xml-mapping-metadata-complete/>
  </persistence-unit-metadata>

P.S. Is your name really Susie Derkins?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 09, 2006 7:09 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hi Susie.
I expect very few people using orm.xml rather than annotations. Like Checked/Runtime exceptions, the war is going to be over soon :-)

However, I'm really interested in your feedback (both on documentation and bug report). Feel free to contact me directly on those. I know my documentation suck in this area.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 07, 2006 10:38 am 
Newbie

Joined: Wed May 31, 2006 6:40 am
Posts: 19
emmanuel wrote:
Hi Susie.
I expect very few people using orm.xml rather than annotations. Like Checked/Runtime exceptions, the war is going to be over soon :-)

However, I'm really interested in your feedback (both on documentation and bug report). Feel free to contact me directly on those. I know my documentation suck in this area.


i'm interested to Merge annotation and orm mapping...
i have automatically generated pojo & dao & interfaces for ejb3... but i like a way to add custom query not hard-coded...
i mean.. like store procedures... i like to have a "login" named query in orm.xml so i can modify it without modify the code & recompile....
or.. even better... i hope without even shut down application!!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 07, 2006 1:41 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
answered where the original question was posted

_________________
Emmanuel


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