Hi,
I am looking to dynamically load the data for the entire record shown below without actually specifying each property in the mapping XML file. This is a requirement of the program that I am writing, as the Hibernate code must work without configuration modification if columns are added to or take out of the database. Is this possible?
I noticed that there was at one point an XML element named "dynamic-class" that was taken out of the DTD. Did this have anything to do with what I am looking to do?
The hibername.default_entity_mode for the SessionFactory is set to "dynamic-map".
Also, I apologize if I did not get the terminology correct. I am fairly new to Hibernate.
Thank you.
Hibernate version: 3.0.5
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="mypackage">
<class table="position" entity-name="DEFAULT" lazy="false">
<composite-id name="key" class="maypackage.MyKeyClass">
<key-property name="col1" />
<key-property name="col2" />
</composite-id>
<!-- It works with the following line uncommented: -->
<!-- <property name="col3" type="string" /> -->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Map m = new HashMap();
m.put("col1", col1Value);
m.put("col2", col2Value);
Map p = (Map) session.load("DEFAULT", (Serializable) m);
System.out.println("This should not be null: " + p.get("col3"));