-->
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.  [ 6 posts ] 
Author Message
 Post subject: composite-id class is not instantiated
PostPosted: Tue Aug 16, 2005 9:41 am 
Newbie

Joined: Fri Feb 27, 2004 7:55 am
Posts: 17
Hibernate version: 3.0.5

Mapping documents:

<class lazy="true" entity-name="BusinessObject" table="BusinessObject">
<composite-id name="_id" class="de.companio.f5.persistence.CompositeId">
<key-property name="id0" type="string" column="BOBJID"/>
</composite-id>
...
</class>

The BusinessObject entity uses a dynamic model. Therefore a Map is returned when a BusinessObject entity is loaded.

Yet, this map contains a HashMap for the "_id" key. In other words: the class that is specified for the composite-id is not instantiated.

(The HashMap that is returned for the "_id"-key contains an entry for "id0".)


Top
 Profile  
 
 Post subject: composite-id class not supported with dynamic models?
PostPosted: Tue Aug 16, 2005 12:52 pm 
Newbie

Joined: Fri Feb 27, 2004 7:55 am
Posts: 17
Looking at the source code of hibernate 3.0.5 I found the following lines in TuplizerLookup:

public static TuplizerLookup create(Component component) {
PersistentClass owner = component.getOwner();

Tuplizer dmt = new DynamicMapComponentTuplizer(component);

Tuplizer pt = owner.hasPojoRepresentation() && component.hasPojoRepresentation() ?
new PojoComponentTuplizer(component) : dmt;

Tuplizer d4jt = owner.hasDom4jRepresentation() ?
new Dom4jComponentTuplizer(component) : null;

return new TuplizerLookup(pt, dmt, d4jt);
}

It seems that composite ids (i.e. components) are never tuplized into PoJos if their owner has not a PoJo representation.

Is there a reason for this behaviour?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 4:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Um. Sounds like very reasonable behavior to me....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 17, 2005 3:01 am 
Newbie

Joined: Fri Feb 27, 2004 7:55 am
Posts: 17
I have a "dynamic" composite-id class that fits all my dynamic entities and that I would like to be instantiated.

The problem I see is that equals and hashCode do not work with "HashMap"-ids. In the Hibernate documentation I read that it is important for composite id classes to implement these methods. That's the reason why I implemented a "dynamic" composite-id class.

Wouldn't it be possible to have the composite-id classes instantiated if the "class" attribute is explicitly set?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 26, 2005 3:46 am 
Newbie

Joined: Fri Feb 27, 2004 7:55 am
Posts: 17
Is there anybody out there who can resolve my concerns?

In other words, is it not necessary for dynamic models that there composite ids have equals and hashCode implemented based on the value of the key fields?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 29, 2005 12:22 pm 
Newbie

Joined: Fri Feb 27, 2004 7:55 am
Posts: 17
I got it! A map is a perfect composite id because equals and hashCode is specified to be basec on the values of the map.


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