My question is more about practice and how to implement rather than a specific question. I'm using hibernate with the Spring framework.
I have an object which forms the root of an object graph. This Event object maps to a table in Oracle. Triggers populate this "event" table with information about what has happend in a work flow. When an event occurs one or more, upto three possible foreign keys, may be populated in the event. Information in the event object tells me which relationships will actually have relationships to other objects that the event describes. For instance the Event.triggerType() might indicate that a row in another table, representing a document, had been deleted. In this case, the entry in the DOCID column would be present but the target row, in the document table would have been deleted already.
These other relationships are in two cases, one to one relationships and in one case is a one to many (an event may have many tasks). When I tried to map the relationships, I found that I had exceptions being thrown when the keys had values but the referenced data didn't exist. Because Hibernate was trying to fetch the data from the other tables which didn't exist.
My first attempt to fix the problem was to take the following tact.
<class name="Document" table="HVDocument" lazy="true">
which from my reading of the documentation suggest that a proxy will be used on relationships that involve the Document class. This allows me to fetch the Events and so gets me past my first hurdle.
However, now, in cases when I try to reference the document where I know there is a row in the document table, I get an error message that references the proxy. ( I apologize, I don't have the exact text of the message, I'm posting from home.)
So my general question is. How do I map this situation, what special circumstances do I have to consider and what issues should I be aware of when I use lazy as a class attribute and thus end up with proxies representing my entities.
I've had extensive experience with EOF, and this would be extremely simple in EOF, so I'm just a bit frustrated.
Tony
|