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: Hibernate DTD inconsistent with usage and code!
PostPosted: Fri Sep 24, 2004 10:09 am 
Newbie

Joined: Fri Sep 24, 2004 9:47 am
Posts: 2
Location: Sydney, Sunny Australia
The problem:
=========
1. The DTD for the SET element doesn't include the "name" attribute
2. All of the examples for Hib 2.1.6 include a name attribute however
3. The code expects (and poorly catches if not present - eg NPE's) a name attribute for all collections. (I've checked out and fixed the code to report this better - patch available if required)

If it validates against the DTD (validation is on by default) then your code will break. If you leave out the name attribute then your code will break.

XDoclet generates the doctype (and hence the DTD specifier by default)...

Rock [ me ] Hard place...

:)

Thoughts very welcome - in the meantime I'm running with my modified jar.

Attachments
========
The DTD for SET is as follows (from http://hibernate.sourceforge.net/hibern ... ng-1.1.dtd)

<!ELEMENT set (
jcs-cache?,
(key|generated-key),
(element|one-to-many|many-to-many|subcollection|composite-element)
)>
<!ATTLIST set role CDATA #REQUIRED>
<!ATTLIST set table CDATA #IMPLIED> <!-- default: rolename -->
<!ATTLIST set schema CDATA #IMPLIED> <!-- default: none -->
<!ATTLIST set lazy (true|false) "false">
<!ATTLIST set sort CDATA "unsorted"> <!-- unsorted|natural|"comparator class" -->
<!ATTLIST set readonly (true|false) "false">
<!ATTLIST set cascade (none|all|save-update|delete) #IMPLIED> <!-- default: none -->
<!ATTLIST set order-by CDATA #IMPLIED> <!-- default: none -->

An example of the usage of "set" is:
=======================
<set name="subDetails" lazy="true" cascade="all">
<key column="detail_key"/>
<one-to-many class="org.hibernate.test.SubDetail"/>
</set>
(MasterDetail.hbm.xml)
-- Note the name attribute

_________________
Best regards

David


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 24, 2004 10:12 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: Re: Hibernate DTD inconsistent with usage and code!
PostPosted: Fri Sep 24, 2004 9:02 pm 
Newbie

Joined: Fri Sep 24, 2004 9:47 am
Posts: 2
Location: Sydney, Sunny Australia
** Max sheepishness **

Sorry about this, yes - somehow the V2 tag from hibernatedoclet in the Ant build went missing and it generated 1.1 code.

Recommendation however:
=================
Add a "version" attribute to the hbm.xml root node. This version would be checked by Hibernate on startup and barf with a reasonable error message (as opposed to the NPE I was getting). Far more reasonable behaviour, and trivial to implement.

_________________
Best regards

David


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.