db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Mann <Dav...@invera.com>
Subject FW: Mapping multiple objects to the same table
Date Mon, 08 Sep 2003 20:31:47 GMT

[This message was resent when it was determined that the first attempt
failed]

Our tests show that the generated SQL statements (using rc-4) are out or
whack on n-1 class to table mappings.

As example, Mapping A maps Class A to fully table A, say 20 columns.
Mapping B maps to Table A, mapping only the PK and a couple of addition
columns. Queries run on mapping B show select statements for the entire 20
columns in the spy log. When you experiment by changing Mapping B's table
attribute to lower case (Mapping A.table = "test_table", Mapping B.table =
"TEST_TABLE"), you end up with queries on Mapping B generating the smaller
select list (important when using thins like distinct, ordering, or avoiding
blob columns, ....).  

David Mann
Montreal


-----Original Message-----
From: Thomas Mahler [mailto:thma32@web.de]
Sent: Wednesday, September 03, 2003 4:03 AM
To: OJB Developers List
Subject: Re: Mapping multiple objects to the same table


Hi David,

David Mann wrote:
> It seems like OJB may have some objection to mapping more than one class
to
> a table.  

Why do you think so?

> Examples of this could be classes with a subset of properties
> commonly used in queries (lightweight), .... to allow use of the
> PersistenceBroker getCollectionByQuery API.  

Exactly. And that's why we even recommend this kind of mapping as best 
practise for certain situations.

Here is a recent sample posting from our user list:
"I have got a solution of Tomas Mahler and thought that I would share 
it. It is very simple once you realise that there arn't a 1-1 relation 
between class-description and database-table but a n-1. You can have as 
many classes mapping to one database-table as you like and find use of.

So the solution to how to avoid an OutOfMemory error handling blobs are 
to separate your class holding the blob into two. If you like me have a
Picture-class separate them into  PictureInfo and  PictureData where the
PictureInfo holds all values about the picture that are not the 
picture-data while the PictureData only holds the id and data. When you 
need the data of the picture let the PictureInfo-class load an object of 
PictureData (lazy-loading)."


> While it can be subverted by
> changing case of the table attribute in the class descriptor, I cannot
> determine why the objection in the first place. >
> Is there any problems in pursuing this pattern of usage ?
>
As mentioned above: there is NO problem with this approach.
If there are spots in our documentation that gave you this impression we 
have to change them! Where did you get this from?

cheers,
Thomas

> David Mann
> Montreal
>  
>  
> 
> 
>
****************************************************************************
> 
> This e-mail may be privileged and/or confidential, and the sender does not
> waive any related rights and obligations. Any distribution, use or copying
> of this e-mail or the information it contains by other than an intended
> recipient is unauthorized. If you received this e-mail in error, please
> advise me (by return e-mail or otherwise) immediately. 
> 
> Ce courriel est confidentiel et protégé. L'expéditeur ne renonce pas aux
> droits et obligations qui s'y rapportent. Toute diffusion, utilisation ou
> copie de ce message ou des renseignements qu'il contient par une personne
> autre que le (les) destinataire(s) désigné(s) est interdite. Si vous
recevez
> ce courriel par erreur, veuillez m'en aviser immédiatement, par retour de
> courriel ou par un autre moyen.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


****************************************************************************

This e-mail may be privileged and/or confidential, and the sender does not
waive any related rights and obligations. Any distribution, use or copying
of this e-mail or the information it contains by other than an intended
recipient is unauthorized. If you received this e-mail in error, please
advise me (by return e-mail or otherwise) immediately. 

Ce courriel est confidentiel et protégé. L'expéditeur ne renonce pas aux
droits et obligations qui s'y rapportent. Toute diffusion, utilisation ou
copie de ce message ou des renseignements qu'il contient par une personne
autre que le (les) destinataire(s) désigné(s) est interdite. Si vous recevez
ce courriel par erreur, veuillez m'en aviser immédiatement, par retour de
courriel ou par un autre moyen.

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message