Hello All,
We have 2 tables a POINTER_CACHE and PERSON_ACTIVITY_HEADERS table. We are using the Hibernate Dom4J capabilities and for the most part they are working great.
The Header table is associated with the Cache table using a foreign key. In my code, however, I am unable to extract this foreign key from the DOM4J node that is returned that represents the header table. The abbrieviated mapping file follows:
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>
<class entity-name="personActivityHeader" table="PERSON_ACTIVITY_HEADERS" node="personActivityHeader" >
<id name="id" column="ID" node="@id" type="int">
<generator class="native" />
</id>
<property name="submitter" node="submitter" type="string" index="pah_sub" />
<property name="personFirstName" node="personFirstName" type="string" index="pah_pfn" />
<property name="personLastName" node="personLastName" type="string" index="pah_pln" />
</class>
<class entity-name="pointer" table="POINTER_CACHE" node="pointer" >
<id name="id" column="ID" node="@id" type="int">
<generator class="native" />
</id>
<property name="serializedForm" column="XML_DATA" type="text" node="serialized" />
<component name="content" node="content" >
<set name="personActivityHeaders" node="." cascade="all" embed-xml="true">
<key column="pointerId" not-null="true"/>
<one-to-many entity-name="personActivityHeader" node="personActivityHeader"/>
</set>
</component>
</class>
</hibernate-mapping>
Then I retrieve the node as XML with the following Java code snippet:
Code:
List l = getHibernateTemplate().findByCriteria(searchCriteria);
Iterator i = l.iterator();
int recordCount = 0;
while(i.hasNext()) {
Element e = (Element)i.next();
Element f = (Element)getHibernateTemplate().get("pointer", Integer.valueOf(e.attribute("id").getStringValue()));
}
My question is, how do I get data from the "pointer" table using the "pointerId" foriegn key? When I print the Element 'e' that I retrieve from the database it looks like this:
<personActivityHeader id="166">
<personFirstName>Charley</personFirstName>
<personLastName>Test2</personLastName>
</personActivityHeader>
I can not, however, get the 'pointerId' out.
I inherited this code and I am learning as I go along so any assistance would be much appreciated.
Thanks!
Yogesh[/code]