-->
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: How to map parameterized UserType as part of a collection
PostPosted: Wed Feb 08, 2006 3:36 pm 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Hi,
I'm stuck with a problem concerning mapping a parameterized UserTypes as a collection.

I have the following class:
Code:
public class MyCLass{
...
    private Set<PiecelistElement> ples;
...
}


I would like to populate the set using a parameterized UserType. I could imagine the following:
Code:
<set name="ples" table="MY_PLES_TABLE">
        <key column="myClassId"/>
        <element>
            <type name="my.comp.common.hibernate.PleType">
                <param name="type">my.comp.domain.PleElement</param>
            </type>
        </element>
</set>

Unfortunately this mapping isn't possible. I read in another posting here that this relates to an incomplete dtd definition of element in the hibernate mappings dtd (http://forum.hibernate.org/viewtopic.php?t=944563&start=0&postdays=0&postorder=asc&highlight=collection+usertype)

Any help on this is highly appreciated.

Hibernate version: 3.1.1

Mapping documents:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 9:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
What happens if you try a type definition and then use <element type="your-type-def-name"/>? Should work. In that case would just be an omision in the DTD.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 5:45 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Hi Steve,
thanks for your quick answer. Basically your solution would work with a non parameterized UserType, but in this case I need to be able to pass a parameter to the UserType.

I have patched the element definition of the hibernate-mapping dtd as follows and this appears to work:
Code:
<!-- Declares the element type of a collection of basic type -->

<!ELEMENT element (column|formula|type)*>
   <!ATTLIST element column CDATA #IMPLIED>
   <!ATTLIST element node CDATA #IMPLIED>
   <!ATTLIST element formula CDATA #IMPLIED>
   <!ATTLIST element type CDATA #IMPLIED>
   <!ATTLIST element length CDATA #IMPLIED>
   <!ATTLIST element precision CDATA #IMPLIED>
   <!ATTLIST element scale CDATA #IMPLIED>
   <!ATTLIST element not-null (true|false) "false">
   <!ATTLIST element unique (true|false) "false">


Do you want me to rise a JIRA Task for an update of the DTD?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 9:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
type defs *can be* parameterized.

Sure, enter a JIRA issue so I don't forget


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 9:20 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Brilliant... I didn't get to the idea of adding the param in the typedef.

Thanks a lot...

Nevertheless I have just added a JIRA task for the extension of the DTD: HHH-1470


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.