Hi Shiva,

I'm really suprised too as I never thought this could work.

Sorry for giving you wrong information
Ralf


Shiva P. Kodityala schrieb:

I am sorry to bother you. Just wanted to check what the error would be: 
Surprisingly, it got the correct results.

My data from tables:

Not defined any keys on table9.

SQL> select * from table9;

COL1  COL2  COL3  COL4  COL5  COL6
----- ----- ----- ----- ----- -----
c11   c12   c13   d141  d151  d161
c11   c12   c13   d142  d152  d162
c11   c12   c13   d143  d153  d163
c21   c22   c23   d241  d251  d261
c21   c22   c23   d242  d252  d262
c21   c22   c23   d243  d253  d263
c31   c32   c33   d341  d351  d361
c31   c32   c33   d342  d352  d362
c31   c32   c33   d343  d353  d363

9 rows selected.
----------------------------------------------------------------
Mapping:
<class name="com.scif.test.Table81" identity="col1"> <description>Map to Table9</description> <map-to table="Table9"/> <field name="col1" type="string"> <sql name="col1" type="varchar"/> </field> <field name="col2" type="string"> <sql name="col2" type="varchar"/> </field> <field name="col3" type="string"> <sql name="col3" type="varchar"/> </field> <field name="details" type="com.scif.test.Table82" collection="vector" > <sql many-key="col1" /> </field> </class> <class name="com.scif.test.Table82" identity="col4"> <description>Map to Table9</description> <map-to table="Table9"/> <field name="col4" type="string"> <sql name="col4" type="varchar"/> </field> <field name="col5" type="string"> <sql name="col5" type="varchar"/> </field> <field name="col6" type="string"> <sql name="col6" type="varchar"/> </field> <field name="col1" type="com.scif.test.Table81"> <sql name="col1" /> </field> </class> -------------------------------------------------------

Output - Resultset from Query :

[EMAIL PROTECTED]
col1:c11
col2:c12
col3:c13
size of details:3
col1 in Table82:[EMAIL PROTECTED]
col4 in Table82:d141
col5 in Table82:d151
col5 in Table82:d161
col1 in Table82:[EMAIL PROTECTED]
col4 in Table82:d142
col5 in Table82:d152
col5 in Table82:d162
col1 in Table82:[EMAIL PROTECTED]
col4 in Table82:d143
col5 in Table82:d153
col5 in Table82:d163
[EMAIL PROTECTED]
col1:c21
col2:c22
col3:c23
size of details:3
col1 in Table82:[EMAIL PROTECTED]
col4 in Table82:d241
col5 in Table82:d251
col5 in Table82:d261
col1 in Table82:[EMAIL PROTECTED]
col4 in Table82:d242
col5 in Table82:d252
col5 in Table82:d262
col1 in Table82:[EMAIL PROTECTED]
col4 in Table82:d243
col5 in Table82:d253
col5 in Table82:d263
[EMAIL PROTECTED]
col1:c31
col2:c32
col3:c33
size of details:3
col1 in Table82:[EMAIL PROTECTED]
col4 in Table82:d341
col5 in Table82:d351
col5 in Table82:d361
col1 in Table82:[EMAIL PROTECTED]
col4 in Table82:d342
col5 in Table82:d352
col5 in Table82:d362
col1 in Table82:[EMAIL PROTECTED]
col4 in Table82:d343
col5 in Table82:d353
col5 in Table82:d363
-------------------------------------------------------

-----Original Message-----
From: Ralf Joachim [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 23, 2005 9:02 AM
To: [email protected]
Subject: Re: [castor-user] A mapping question


Shiva,

it is possible to map 2 different classes to the same table even if you
need to be aware of problems when changed objects are persisted or
loaded after that change. The problem is that both classes have separate
caches and they get inconsistent when objects are changed. The best idea
to omit these problems is to switch of caching for both of this classes.

The many problem you will have with your idea is that every object needs
a unique identity. If you create class A for (col1, col2, col3) for the
1 side of your 1:m relation, you will not have a unique identity as
there will be multiple records for all combinations of (col1, col2,
col3) in the database. For class B, m side of the 1:m relation, holding
values of the columns (col4, col5, col6) there may be similar problems
as I don't know if one (or a combination) of the columns can be used as
identity. If you do not have columns in (col1, col2, col3, col4, col5,
col6) that can be used as identity (primary key) it will not be possible
to use castor to access this data at all. You should also be aware that
castor do not support foreign keys that are part of primary keys.

Without more details on the constraints of the data in the table it is
impossible for me to tell you if and how you can map this data with
castor. It would also be important if you only want to load the data or
if you also want to create new or update existing ones. But even if the
constrains are ideal it will not be possible to load the data into 2
classes with a 1:m relation directly by castor.

Regards
Ralf


Shiva P. Kodityala schrieb:
Ralf

Is it not possible because both the classes point to the same table? Or some 
other reason?

Thanks

-----Original Message-----
From: Ralf Joachim [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 23, 2005 8:08 AM
To: [email protected]
Subject: Re: [castor-user] A mapping question


Hi Shiva,

I'm sorry but this is not possible with castor at the moment. You need
to find a workaround on your java objects for this to work.

Regards
Ralf


Shiva P. Kodityala schrieb:

I have an not-normalized table which is already existing.
tableX(col1, col2, col3,col4,col5,col6)

For every (col1, col2, col3), there are number of(col4,col5,col6). Can I have a classA mapping to first part and classB mapping to second part and have a relation 1:m? - Is it possible? If so, do I have to take any precautions? If not, what is the better approach? Of course, I am not authorized to change the design of existing table. So, Both the classes point to the same table. Ultimately, I want to get normalized data into my java objects without extra processing.
Thanks for help.


-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------
-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------


-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------



-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to