-->
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: Best way to Map HashMap or java.util.Properties class ????
PostPosted: Thu Aug 12, 2004 12:03 pm 
Newbie

Joined: Thu Aug 12, 2004 9:32 am
Posts: 17
Hibernate version:2.1.6

using:Oracle 8i

Hi,
I am new to Hibernate.
I have some classes with simple HashMaps or Properties members.

they are usually contains Key-string and Value-string

can someone please show me what should be the Mapping for such a class and how should it look like in the database ?

I tried somthing like :
class :
Code:
public class Group {
   private String      id;
   public  String       name;
   public  String       gdlName;
   public  HashMap    gdlArgs;   

Oracle :
Code:
               GRP3
Name                 Type
------------------  ------------
ID                      VARCHAR2(40)
NAME                  VARCHAR2(40)
GDLNAME            VARCHAR2(40)
GDLARGS_ID       NUMBER(10)

         GDLARGS
Name                       Type
-------------------- ------------
GDLARGS_ID       NUMBER(10)
KEY                     VARCHAR2(40)
VALUE                 VARCHAR2(40)

and Map :
Code:
    <class name="test.hibernate.Group" table="GRP3">
        <id name="id" type="string" unsaved-value="null" >
            <column name="id" sql-type="char(32)" not-null="true"/>
            <generator class="uuid.hex"/>
        </id>
        <property name="name">
            <column name="name" sql-type="char(40)" not-null="true"/>
        </property>
        <property name="gdlName">
            <column name="gdlName" sql-type="char(40)" not-null="true"/>
        </property>
       
        <map name="gdlArgs" table="GDLARGS">
              <key>
     <column name="GDLARGS_ID" sql-type="NUMBER(10)" />
               </key>
            <index type="object" column="KEY" />
           <element type="object" column="VALUE" />
        </map>
    </class>



I got collection element mapping has wrong number of columns
and when index/element type were string instead of "object" i got :
Quote:
exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of test.hibernate.Group.setGdlArgs


What am I doing wrong ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 12:22 pm 
Beginner
Beginner

Joined: Mon Aug 09, 2004 12:31 pm
Posts: 47
Location: New York, NY, USA
I think you have to specify access=field in the map declaration

_________________
--DP


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 12:22 pm 
Beginner
Beginner

Joined: Mon Aug 09, 2004 12:31 pm
Posts: 47
Location: New York, NY, USA
Sorry, that should be

Code:
access="field"

_________________
--DP


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 3:57 am 
Newbie

Joined: Thu Aug 12, 2004 9:32 am
Posts: 17
I added access="filed" as :
Code:
..
..
<map name="gdlArgs" table="GDLARGS" access="field">
   <key>
       <column name="GDLARGS_ID" sql-type="NUMBER(10)" />
   </key>
   <index type="string" column="KEY" />
   <element type="string" column="VALUE" />   
</map>


and I got :
could not set a field value by reflection setter of test.hibernate.Group.gdlArgs[/quote]


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.