hi,

ojb fires a query for each extent (subclass) residing in it's own table. extents in the same table (using ojbConcreteClass) are retrieved with one query.
this behaviour has the advantage that it runs on all dbms (an alternative would be to use UNION) ! on the other hand, we need multiple queries an we cannot sort the whole result :(


hth
jakob

Crecente Casanova, David wrote:

<<<
  Hi,
  I don't know to do this task with only one query. I don't belive ojb can do it, but 
if you see the broker or query object in the API may be you find something.

For storing you need 2 queries too. I don't know other way.



-----Mensaje original----- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Enviado el: viernes, 08 de agosto de 2003 13:51 Para: OJB Users List Asunto: RE: one table -> multiple classes problem


Hi,


thanks for your answer. Correct me if i am wrong, but as far
as i can read you xml files, you need to run 2 queries to
get your 2 classes. I need to run 3 queries (actually there is one
more address, so i need to run 4 queries) to load all the data
i need from the database.  This should be no problem, but i am
wondering if it is not possible to do this in one step (1 query ->
all 4 object will be loaded) ?
getting each object separately i have 4 db accesses instead of 1 !

just wondering,

Andreas



  Hi,
  you can do it without problem.

I have two classes for one table.

  Classes: Crm_cliente_masinfo, Crm_cliente_general
  Ta
ble: CRM_CLIENTE

(1)First xml descriptor.

<!-- This repository file
is generated by the impart OJB Generator -->
<!--           www.impart.
ch [EMAIL PROTECTED]                        -->
<!--        created at 9 Ju
l 2003 11:37:50 GMT                     -->



<class-descriptor class="com.indra.crm.vo.Crm_cliente_masinfo"
table="CRM_CLIENTE"


<field-descriptor id="66"
name="ln_id_cliente"
column=
"LN_ID_CLIENTE"
jdbc-type="INTEGER"
primarykey="true"
aut
oincrement="true"
sequence-name="sec_cliente"
/>
<field-descr
iptor id="73"
name="ds_url"
column="DS_URL"
jdbc-typ
e="VARCHAR"
/>
<field-descriptor id="74"
name="ts_coment
ario"
column="TS_COMENTARIO"
jdbc-type="VARCHAR"
/>
<
field-descriptor id="79"
name="ln_facturacion"
column="LN
_FACTURACION"
jdbc-type="INTEGER"
/>
<field-descriptor id=
"80"
name="mn_nu_empleados"
column="MN_NU_EMPLEADOS"
j
dbc-type="INTEGER"
/>
<field-descriptor id="81"
name="mn
_nu_fact_emp"
column="MN_NU_FACT_EMP"
jdbc-type="INTEGER"
/>
<field-descriptor id="82"
name="sn_movil_emp"
colum
n="SN_MOVIL_EMP"
jdbc-type="INTEGER"
/>
<field-descriptor id="83"
name="sn_nu_sedes"
column="SN_NU_SEDES"
jdbc
-type="INTEGER"
/>
<field-descriptor id="84"
name="sn_nu
_sedes_hfc"
column="SN_NU_SEDES_HFC"
jdbc-type="INTEGER"


/>
<field-descriptor id="85"
name="ln_potencial_total"
column="LN_POTENCIAL_TOTAL"
jdbc-type="INTEGER"
/>
<field-
descriptor id="86"
name="ln_potencial_fijo"
column="LN_PO
TENCIAL_FIJO"
jdbc-type="INTEGER"
/>
<field-descriptor id=
"87"
name="ln_potencial_movil"
column="LN_POTENCIAL_MOVIL"
jdbc-type="INTEGER"
/>
<field-descriptor id="88"
name=
"ln_potencial_datos"
column="LN_POTENCIAL_DATOS"
jdbc-type=
"INTEGER"
/>
<field-descriptor id="89"
name="ln_potencial_
fijo_emp"
column="LN_POTENCIAL_FIJO_EMP"
jdbc-type="INTEGER
"
/>
<field-descriptor id="90"
name="ln_potencial_datos_em
p"
column="LN_POTENCIAL_DATOS_EMP"
jdbc-type="INTEGER"
/


<field-descriptor id="91"
name="ln_potencial_movil_emp"
column="LN_POTENCIAL_MOVIL_EMP"
jdbc-type="INTEGER"
/>
<
field-descriptor id="92"
name="sn_id_usuario_alta"
column=
"SN_ID_USUARIO_ALTA"
jdbc-type="INTEGER"
/>
<field-descripto
r id="93"
name="dt_fh_alta"
column="DT_FH_ALTA"
jdbc
-type="TIMESTAMP"
/>
<field-descriptor id="94"
name="sn_
id_usuario_mod"
column="SN_ID_USUARIO_MOD"
jdbc-type="INTEG
ER"
/>
<field-descriptor id="95"
name="dt_fh_mod"
col
umn="DT_FH_MOD"
jdbc-type="TIMESTAMP"
/>
<field-descriptor
id="96"
name="sn_id_usuario_baja"
column="SN_ID_USUARIO_
BAJA"
jdbc-type="INTEGER"
/>
<field-descriptor id="97"
name="dt_fh_baja"
column="DT_FH_BAJA"
jdbc-type="TIMEST
AMP"
/>


</class-descriptor>


(2) Second xml descriptor


<!-- This repository file is generated by the impart OJB Generator -->
<!-- www.impart.ch [EMAIL PROTECTED] -->
<!-- created at 9 Jul 2003 11:37:50 GMT -->




<c
lass-descriptor class="com.indra.crm.vo.Crm_cliente_general"
tab
le="CRM_CLIENTE"


 <field-descriptor id="66"
   name="ln_id_c
liente"
   column="LN_ID_CLIENTE"
   jdbc-type="INTEGER"
   pri
marykey="true"
        autoincrement="true"
        sequence-name="sec_cliente"

/>
<field-descriptor id="67"
name="ds_nb_cliente"
co
lumn="DS_NB_CLIENTE"
jdbc-type="VARCHAR"
/>
<field-descrip
tor id="68"
name="ss_cif"
column="SS_CIF"
jdbc-type=
"VARCHAR"
/>
<field-descriptor id="69"
name="sn_lv_tipo_cl
iente"
column="SN_LV_TIPO_CLIENTE"
jdbc-type="INTEGER"
/


<field-descriptor id="70"
name="sn_lv_estado"
column=
"SN_LV_ESTADO"
jdbc-type="INTEGER"
/>
<field-descriptor id=
"71"
name="sn_id_gestor_asignado"
column="SN_ID_GESTOR_ASIG
NADO"
jdbc-type="INTEGER"
/>
<field-descriptor id="72"
name="sc_gran_cliente"
column="SC_GRAN_CLIENTE"
jdbc-type
="CHAR"
/>
<field-descriptor id="74"
name="ln_jefe_proye
cto"
column="LN_JEFE_PROYECTO"
jdbc-type="VARCHAR"
/>


<field-descriptor id="76"
name="ms_id_migracion"
column=
"MS_ID_MIGRACION"
jdbc-type="VARCHAR"
/>
<field-descriptor i
d="77"
name="ms_id_codigo_amena"
column="MS_ID_CODIGO_AME
NA"
jdbc-type="VARCHAR"
/>
<field-descriptor id="78"
name="ms_id_codigo_auna_tlc"
column="MS_ID_CODIGO_AUNA_TLC"
jdbc-type="VARCHAR"
/>
<field-descriptor id="92"
name="
sn_id_usuario_alta"
column="SN_ID_USUARIO_ALTA"
jdbc-type="
INTEGER"
/>
<field-descriptor id="93"
name="dt_fh_alta"


  column="DT_FH_ALTA"
   jdbc-type="TIMESTAMP"
 />
 <field-des
criptor id="94"
   name="sn_id_usuario_mod"
   column="SN_ID_US
UARIO_MOD"
   jdbc-type="INTEGER"
 />
 <field-descriptor id="95
"
   name="dt_fh_mod"
   column="DT_FH_MOD"
   jdbc-type="TIM
ESTAMP"
 />
 <field-descriptor id="96"
   name="sn_id_usuario_b
aja"
   column="SN_ID_USUARIO_BAJA"
   jdbc-type="INTEGER"
 />
 <field-descriptor id="97"
   name="dt_fh_baja"
   column="DT_
FH_BAJA"
   jdbc-type="TIMESTAMP"
 />
 <field-descriptor id="98
"
   name="ln_id_cliente_padre"
   column="LN_ID_CLIENTE_PADRE"
   jdbc-type="INTEGER"
 />
 <field-descriptor id="99"
   name=
"ss_mig_cif_aunatlc"
   column="SS_MIG_CIF_AUNATLC"
   jdbc-type=
"VARCHAR"
 />

</class-descriptor>


(3) My repository.xml


<?xm
l version="1.0" encoding="UTF-8"?>
<!-- defining entities for includ
e-files -->
<!DOCTYPE descriptor-repository SYSTEM "repository.dtd" [

<!ENTITY CRM_CLIENTE_GENERAL SYSTEM "crm_cliente_repositorio_general.xml"


        <!ENTITY CRM_CLIENTE_MASINFO SYSTEM "crm_cliente_repositorio_masinfo.
xml">
]>
<!-- This is a sample metadata repository for the ObJectBridge
System.

    Use this file as a template for building your own mappin
gs-->
<!-- defining entities for include-files -->
<descriptor-reposito
ry isolation-level="read-committed" version="1.0">
        <!-- The Default
JDBC Connection. If a class-descriptor does not specify its own JDBC Con
nection,

the Connection specified here will be used. -->
<jdbc-
connection-descriptor dbalias="thin:@IP:PORT:SID" useAutoCommit="2" d
efault-connection="true" driver="com.p6spy.engine.spy.P6SpyDriver" jc
d-alias="" jdbc-level="2.0" password="CRM_AGC" platform="Oracle" protocol="jdbc" subprotocol="oracle" username="CRM_AGC">
<connec
tion-pool logAbandoned="true" maxActive="1" maxIdle="1" maxWait="
5000" removeAbandoned="true" />
<sequence-manager className="org.
apache.ojb.broker.util.sequence.SequenceManagerNextValImpl"/>
</jdbc-co
nnection-descriptor>
<!-- Enlace que apunta a CRM_USUARIO -->
&CRM_CLI
ENTE_GENERAL;
&CRM_CLIENTE_MASINFO;


        <!-- This repository file is gen
erated by the impart OJB Generator -->
        <!--           www.impart.ch inf
[EMAIL PROTECTED]                        -->
        <!--        created at 8 Jul 200
3 08:50:17 GMT                     -->
</descriptor-repository>





-----Mensaje original-----
De: [EMAIL PROTECTED] [mailto:AndreasWues
[EMAIL PROTECTED]
Enviado el: viernes, 08 de agosto de 2003 12:13
Para: ojb-use
[EMAIL PROTECTED]
Asunto: one table -> multiple classes problem


Hi,


i have table that looks like :

table order (
id,
orderid, ..
..
sender_name,
sender_street, ....
recipient_name,
recipient_
street,
..
)


each order consists of some order data, the sender add
ress and the recipient
address.
at the moment i have an order class tha
t contains the sender and the
recipient class (the
sender and recipient
class is basically a class that contains only the
addresses).

class order
{
public Long id;
public Long orderId;
public SenderAddre
ss sender;
public RecipientAddress recipient;
}


is it possible t
o load the order object and also load the sender and
recipient informati
on
in the proper classes in the order object ? I could not find any info
rmation
on how to do that in the documentation.


Unfortunately, norm
alizing the table is not possible.

Any help is really appreciated.

Thanks in advance,

Andreas






-- COMPUTERBILD 15/03 : Premium-e-mail-Dienste im Test --------------------------------------- ----------- 1. GMX TopMail - Platz 1 und Testsieger! 2. GMX ProMail - P latz 2 und Preis-Qualitätssieger! 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post


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

---------------------------------------------------
----------------------------------------------------------------
Este co
rreo electrónico y, en su caso, cualquier fichero anexo al mismo, conti
ene información de carácter confidencial exclusivamente dirigida a su
destinatario o destinatarios. Queda prohibida su divulgación, copia o distribución a terceros sin la previa autorización escrita de Indra. En el caso de haber recibido este correo electrónico por error, se rueg
a notificar inmediatamente esta circunstancia mediante reenvío a la dir
ección electrónica del remitente.


The information in this e-mail a
nd in any attachments is confidential and solely for the attention and us
e of the named addressee(s). You are hereby notified that any disseminati
on, distribution or copy of this communication is prohibited without the prior written consent of Indra. If you have received this communication i
n error, please, notify the sender by reply e-mail


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








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



Reply via email to