-->
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.  [ 4 posts ] 
Author Message
 Post subject: Persisting map with persistable key class
PostPosted: Fri Dec 22, 2006 1:41 pm 
Beginner
Beginner

Joined: Sat Dec 16, 2006 1:52 pm
Posts: 40
I have a class that can contain properties. Like so
Code:
class DBNamedObject extends Xxx{
   Map properties;
    public Map getProperties(){
        return this.properties;
    }
    public String getProperty(DBPropertyType key) {
        return (String)this.properties.get(key);
    }
    public String setProperty(DBPropertyType key, String value){
        return (String)this.properties.put(key,value);
    }
}

in this case DBPropertyType is a persistable class and I am using it for the key to the map. But Hibernate is complaining that it does not know the type of the key!?!

I don't know why because the type is fully defined in the xml file.

Any ideas?

This is the class that contains the map
Code:
<hibernate-mapping>
  <joined-subclass name="com.rgdsft.hibernate.core.models.DBNamedObject" extends="com.rgdsft.hibernate.core.models.DBObject">
    <key column="OBJECT_ID"/>
    <property name="name"
       not-null="true"
       type="string"/>
       
    <map name="properties" table="PROPERTIES">
      <key column="DBNamedObject_ID" not-null="true"/>
      <map-key column="PROPERTY_ID" type="com.rgdsft.hibernate.core.models.DBPropertyType"/>
      <element column="PROPERTY_VALUE" type="string" not-null="true"/>
    </map>

  </joined-subclass>
</hibernate-mapping>

This is the class that is used as a key in the map
Code:
<hibernate-mapping>
  <joined-subclass name="com.rgdsft.hibernate.core.models.DBPropertyType" extends="com.rgdsft.hibernate.core.models.DBObject">
    <key column="OBJECT_ID"/>
    <!-- needs unique name and project -->
    <many-to-one name="project" column="ProjectID" not-null="true"/>

    <property name="name" not-null="true"/>
    <property name="format" not-null="true"/>
    <property name="prepend" not-null="true"/>           
    <property name="postpend" not-null="true"/>
    <property name="isBound" not-null="true"/>
    <property name="isSystem" not-null="true"/>
       
    <set name="boundValues" table="BOUNDVALUES">
      <key column="PROPERTY_ID" on-delete="cascade"/>
      <element column="BoundValue" type="string"/>
    </set>       
       
  </joined-subclass>
</hibernate-mapping>



This is the error
Quote:
org.hibernate.MappingException: Could not determine type for: com.rgdsft.hibernate.core.models.DBPropertyType, for columns: [org.hibernate.mapping.Column(PROPERTY_ID)]


Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 22, 2006 2:45 pm 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
Read:

http://www.hibernate.org/hib_docs/v3/re ... ns-indexed

Indexes of map's need to be "Simple Types" if you use <map-key>

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 22, 2006 2:53 pm 
Beginner
Beginner

Joined: Sat Dec 16, 2006 1:52 pm
Posts: 40
Yes, thank you very much. I changed to map-key-many-to-many and were in business!!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 22, 2006 2:54 pm 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
Please, rate my answer then :)

_________________
andresgr (--don't forget to rate)


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