You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Timofey Korolev <tk...@linux-online.ru> on 2003/06/28 19:39:16 UTC

complex class prolem

Hello there!
I'm new to OJB. I've tried a simple O/R mapping and it worked, but when
i've tried to map real life objects i got a problem.

There are three classes:

LOMGeneralObject & LOMGeneralLanguage & LangString:

public class LOMGeneralObject {
    private BigDecimal identifier;
    private LangString title;
    private BigDecimal titleId;
    private Vector language;
    .....
}

public class LOMGeneralLanguage {
    BigDecimal id;
    String language;
    LOMGeneralObject  gen_object;
    BigDecimal gid;
......
}


public class LangString {
    BigDecimal id;
    String string;
    String language;
....
}

there are also some SQL tables (postgres) for them:

TABLE GENERAL:
IDENTIFIER SERIAL PRIMARY KEY
TITLE DECIMAL(10,0)

TABLE LANGSTRING:
ID SERIAL
LANGUAGE VARCHAR
STRING VARCHAR

TABLE GENERAL_LANGUAGE:
ID SERIAL PRIMARY KEY
LANGUAGE VARCHAR
GID DECIMAL(10,0)


and here goes XML-mapping for them:

 <class-descriptor class="ru.chemnet.lom.LOMGeneralObject"
table="GENERAL"  >

        <field-descriptor name="identifier" column="identifier"
sequence-name="general_identifier_seq" jdbc-type="NUMERIC"
autoincrement="true" primarykey="true" />

        <field-descriptor name="titleId" column="title"
jdbc-type="NUMERIC"/>

        <reference-descriptor name="title"
class-ref="ru.chemnet.lom.LangString" auto-retrieve="true"
auto-update="true" auto-delete="true"  >

            <foreignkey field-ref ="titleId"  />

        </reference-descriptor>

        <collection-descriptor name="language" 
element-class-ref="ru.chemnet.lom.LOMGeneralLanguage" orderby="id"
sort="DESC" >
            <inverse-foreignkey field-ref="gid"/>
        </collection-descriptor>
</class-descriptor>

<class-descriptor class="ru.chemnet.lom.LangString" table="LANGSTRING" >
        <field-descriptor name="id" column="id" jdbc-type="NUMERIC"
autoincrement="true" primarykey="true"
sequence-name="langstring_id_seq"  />
        <field-descriptor name="language" column="language"
jdbc-type="VARCHAR" />
        <field-descriptor name="string" column="string"
jdbc-type="VARCHAR" />
    </class-descriptor>

<class-descriptor class="ru.chemnet.lom.LOMGeneralLanguage"
table="GENERAL_LANGUAGE">
        <field-descriptor name="id" column="id" jdbc-type="NUMERIC"
autoincrement="true" primarykey="true"
sequence-name="general_language_id_seq" />
        <field-descriptor name="language" column="language"
jdbc-type="VARCHAR"/>
        <field-descriptor name="gid" column="gid"  jdbc-type="NUMERIC"/>
        <reference-descriptor name="gen_object"
class-ref="ru.chemnet.lom.LOMGeneralObject" auto-retrieve="true"
auto-update="true" auto-delete="true">
            <foreignkey field-ref="gid"/>
        </reference-descriptor>
    </class-descriptor>


The problem is that I try to make LOMGeneralObject and to store it.
title field of LOMGeneralObject stores to LANGSTRING table perfectly,
but 
LOMGeneralObject.title of Vector type doesn't make any records in
GENERAL_LANGUAGE at all.

I've read Advanced O/R mapping tutorial for hundred times and still
cannot find out what' wrong.
May be someone can help me? Thank you. 



-- 
Regards,
CEO Linux-Online.Ru
Korolyov Timofey

www.linuxshop.ru :: www.prefnews.ru :: www.dotstyle.ru

JabberID: timoha@jabber.ru

Re: complex class prolem

Posted by Timofey Korolev <tk...@linux-online.ru>.
On Sun, 2003-06-29 at 10:56, Christophe Marcourt wrote:
> As it was said to me a few days ago, don't work with Vector but only the
> interface Collection or List.
> It will work then.

Thanks a lot, Christophe!
It's not right, but it's OK  - i'm gonna handle this anyway ;-)
It is also very strange, because examples in Advanced O/R tell that we
CAN use Vector.
here it goes:
class ProductGroup {
	private Vector allArticlesInGroup;
	private String description;
	private int groupId;
	private String groupName;
}

BTW, I've just changed field type from Vector to Collection and got just the same result...


-- 
Regards,
CEO Linux-Online.Ru
Korolyov Timofey

www.linuxshop.ru :: www.prefnews.ru :: www.dotstyle.ru

JabberID: timoha@jabber.ru

Re: complex class prolem

Posted by Christophe Marcourt <cm...@wanadoo.fr>.
As it was said to me a few days ago, don't work with Vector but only the
interface Collection or List.
It will work then.

Christophe

----- Original Message ----- 
From: "Timofey Korolev" <tk...@linux-online.ru>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Saturday, June 28, 2003 7:39 PM
Subject: complex class prolem


> Hello there!
> I'm new to OJB. I've tried a simple O/R mapping and it worked, but when
> i've tried to map real life objects i got a problem.
>
> There are three classes:
>
> LOMGeneralObject & LOMGeneralLanguage & LangString:
>
> public class LOMGeneralObject {
>     private BigDecimal identifier;
>     private LangString title;
>     private BigDecimal titleId;
>     private Vector language;
>     .....
> }
>
> public class LOMGeneralLanguage {
>     BigDecimal id;
>     String language;
>     LOMGeneralObject  gen_object;
>     BigDecimal gid;
> ......
> }
>
>
> public class LangString {
>     BigDecimal id;
>     String string;
>     String language;
> ....
> }
>
> there are also some SQL tables (postgres) for them:
>
> TABLE GENERAL:
> IDENTIFIER SERIAL PRIMARY KEY
> TITLE DECIMAL(10,0)
>
> TABLE LANGSTRING:
> ID SERIAL
> LANGUAGE VARCHAR
> STRING VARCHAR
>
> TABLE GENERAL_LANGUAGE:
> ID SERIAL PRIMARY KEY
> LANGUAGE VARCHAR
> GID DECIMAL(10,0)
>
>
> and here goes XML-mapping for them:
>
>  <class-descriptor class="ru.chemnet.lom.LOMGeneralObject"
> table="GENERAL"  >
>
>         <field-descriptor name="identifier" column="identifier"
> sequence-name="general_identifier_seq" jdbc-type="NUMERIC"
> autoincrement="true" primarykey="true" />
>
>         <field-descriptor name="titleId" column="title"
> jdbc-type="NUMERIC"/>
>
>         <reference-descriptor name="title"
> class-ref="ru.chemnet.lom.LangString" auto-retrieve="true"
> auto-update="true" auto-delete="true"  >
>
>             <foreignkey field-ref ="titleId"  />
>
>         </reference-descriptor>
>
>         <collection-descriptor name="language"
> element-class-ref="ru.chemnet.lom.LOMGeneralLanguage" orderby="id"
> sort="DESC" >
>             <inverse-foreignkey field-ref="gid"/>
>         </collection-descriptor>
> </class-descriptor>
>
> <class-descriptor class="ru.chemnet.lom.LangString" table="LANGSTRING" >
>         <field-descriptor name="id" column="id" jdbc-type="NUMERIC"
> autoincrement="true" primarykey="true"
> sequence-name="langstring_id_seq"  />
>         <field-descriptor name="language" column="language"
> jdbc-type="VARCHAR" />
>         <field-descriptor name="string" column="string"
> jdbc-type="VARCHAR" />
>     </class-descriptor>
>
> <class-descriptor class="ru.chemnet.lom.LOMGeneralLanguage"
> table="GENERAL_LANGUAGE">
>         <field-descriptor name="id" column="id" jdbc-type="NUMERIC"
> autoincrement="true" primarykey="true"
> sequence-name="general_language_id_seq" />
>         <field-descriptor name="language" column="language"
> jdbc-type="VARCHAR"/>
>         <field-descriptor name="gid" column="gid"  jdbc-type="NUMERIC"/>
>         <reference-descriptor name="gen_object"
> class-ref="ru.chemnet.lom.LOMGeneralObject" auto-retrieve="true"
> auto-update="true" auto-delete="true">
>             <foreignkey field-ref="gid"/>
>         </reference-descriptor>
>     </class-descriptor>
>
>
> The problem is that I try to make LOMGeneralObject and to store it.
> title field of LOMGeneralObject stores to LANGSTRING table perfectly,
> but
> LOMGeneralObject.title of Vector type doesn't make any records in
> GENERAL_LANGUAGE at all.
>
> I've read Advanced O/R mapping tutorial for hundred times and still
> cannot find out what' wrong.
> May be someone can help me? Thank you.
>
>
>
> -- 
> Regards,
> CEO Linux-Online.Ru
> Korolyov Timofey
>
> www.linuxshop.ru :: www.prefnews.ru :: www.dotstyle.ru
>
> JabberID: timoha@jabber.ru
>


---
Ce message Envoi est certifié sans virus connu.
Protégé par l'antivirus AVG Deluxe.
Version: 6.0.492 / Base de données virus: 291 - Date: 24/06/2003