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.