-->
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.  [ 5 posts ] 
Author Message
 Post subject: <composite-element> and <meta> problems with co
PostPosted: Fri Apr 02, 2004 12:09 pm 
Newbie

Joined: Fri Apr 02, 2004 11:32 am
Posts: 5
Hi,

I am seeing some odd behaviour with hbm2java.

- hibernate version 2.12
- extensions 2.02.

I am using <meta> tags in my hbm file in order to create base classes (i.e. plumbing/linking etc., occurs in super class). This seemed (from what I have read) to be common practice and worked well... until I required a class with a <composite-element > within a set. I have a simplified mapping below...

Code:
  <class name="test.Test" table="test">
    <meta attribute="generated-class">test.BaseTest</meta>
    <id name="id" column="id" type="long" unsaved-value="0" >
      <generator class="identity" />
    </id>
 
    <property name="name" type="java.lang.String"/>
   
    <set name="members" table="test_members" lazy="true">
       <key column="id"/>
       <composite-element class="test.Member">
          <meta attribute="generated-class">test.Member</meta>
           <property name="memberProperty" type="java.lang.Integer"/>
           <many-to-one name="user" class="com.fonem.vbx.db.User"/>
       </composite-element>
    </set>
  </class> 


There are two <meta> tags in the class definition.

If I omit both of them, the classes are generated as you would expect.

If I insert just the first meta tag to force the generator create 'test.BaseTest', it will only generate one class (test.BaseTest) and the contents of the file are what you would expect in test.Member. i.e. test.BaseTest is generated with properties of memberProperty and user, with id, name, and members nowhere to be seen.

If I insert the both meta tags, specifying that the composite-element class to be test.Member, the problem is solved and the two classes are generated correctly.

So what is the big deal you ask? Well, it seems that I can not use the hbm file with both meta tags, as the standard hibernate parser barfs on it. For example, if I try to generate DDL, I get the following....

Code:
     [java] Caused by: org.xml.sax.SAXParseException: The content of element type "composite-element" must match "(parent?,(property|many-to-one|any|nested-composite-element)*)".


It would seem the dtd being used by the standard parser does not allow meta tags in composite-elements.

- Steven


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 02, 2004 9:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
first thing: put an inherit="false" on your <meta>'s you don't want to "flow down" to embedded parts in your hbm.xml file.

second thing: yes - there seems to be a "bug" in the hibernate-mapping dtd about <meta> ;(

third thing: simple to fix - just add them to the dtd and use it ;)
(and add a jira for it so we remember to fix it)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 03, 2004 12:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Man - I though we caught all of the extra meta tags in the DTD :-(


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 03, 2004 12:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yeah - they seem to creep up on us! :)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 03, 2004 6:23 pm 
Newbie

Joined: Fri Apr 02, 2004 11:32 am
Posts: 5
Thanks.... I had fixed my local dtd to get around the problem but was not aware of the inherit="false" trick. I will submit something to Jira.


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