-->
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.  [ 1 post ] 
Author Message
 Post subject: Is this possible in hibernate ?
PostPosted: Wed Sep 05, 2007 6:18 am 
Newbie

Joined: Wed Sep 05, 2007 3:22 am
Posts: 1
Location: Bangalore
Hi,
This query may look stupid for hibernate(or any ORM) forum. I have just started reading the documentation. Meanwhile any one having insight about this can help.

Is it possible to represent a row using a java Collection instead of using a java bean style POJO. I want to write an application which can write/read any table with ip/op as java collections.

Basically i am looking for something like this.

Code:
<hibernate-mapping>

    <class name="Foo" table="foo">

        <id name="id" column="id" type="int">
            <generator class="assigned"/>
        </id>
        <collection name="ages">
            <key column="id"/>
            <element column="name" type="string"/>
            <element column="age" type="string"/>
            <element column="address" type="string"/>
        </collection>
      </class>
</hibernate-mapping>

and my code would look something like this

            Foo foo = new Foo();
           
//First row
            foo.setId(1);
            Map map = new HashMap();
            map.put("name", "Tom");
            map.put("age", "20");
            map.put("address", "123, abc, xyz");
            foo.setAges(map);
            session.save(foo);
            t.commit();
         
  //second row 
            foo.setId(2);
            Map map1 = new HashMap();
            map1.put("name", "Harry");
            map1.put("age", "23");
            map1.put("address", "456, def, xyz");
            foo.setAges(map1);
            session.save(foo);
            t.commit();
            session.close();



Any pointers would be of great help.

Thanks,
Raameshwar.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.