On Wed, May 28, 2003 at 08:32:16PM +0800, Stephen Ting wrote:
> Hi Jens,
> 
> You're right. That's means this setup won't work. If the Log and
> LogReceiveItem persisting to different table then it should be ok.
> Haven't try, just guessing. 
> 
> How to configure the repository to enable two classes(Log and
> LogReceiveItem, if LogReceiveItem inherit from Log) to persist to the
> same table with LOG_ID as primary key?   

That is easy, just define both classes as usual, with all their
attributes, and map them to the same table. Storing items of both
classes to the LOG-Table should work now without problems.

The problem is when fetching items from db, say for class LogReceiveItem,
you will get instances of model.LogReceiveItem with the data from all 
entries in table LOG, including those you inserted as model.Log, since
OJB does not store the information about the class the data came from at 
storing time. 
You would have to prevent this by using appropriate filter criteria 
by yourself, i.e. look where the attributes which only LogReceiveItem
has are null or not.

I think you should separate the data into two tables and define a 1:1
relationship from LOG_RECEIVE_ITEM to LOG. Imho this would make the
model clearer and easier to understand.


Regards,
Jens

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to