Is it fair to restate your problem as you have a complex data type that you
want to store in a single column of your table, how do you do it.
You could create a converter extending the class FieldConversion that takes
the complex data type (in this case int[]) and converts it to an
appropriate representation for the column. For instance you could encode it
to a string as a comma separated list. You would then write the inverse
conversion that converts it back to an int[] from a comma separated list.
Whether this is "better" of not depends on what otehr requirements there
are on the data.
"Ajitesh Das"
<[EMAIL PROTECTED] To: "OJB Users List"
<[EMAIL PROTECTED]>, "OJB Users
t> List" <[EMAIL PROTECTED]>
cc:
22/01/2003 Subject: Repost***: How to represent a
collection of objects in
09:30 OJB
Please
respond to
"OJB Users
List"
Is there is any *better* way to do this other that creating a seperate
table ? I do not want Join wihile I am getting a attribute only.
=======================================================
But, if the representation is "collection of primitives" instead
of "collection of objects" ,
Do we need to create a sepetrate table.
How do we represent multi-valued primitive attribute ?
For eg:
class MyObj {
int[] winningNumbers;
public int[] getWiningNumbers()
{ return winingNumbers;}
public void setWiningNumbers (int[] no)
{ winingNumbers = no;}
}
how do we represent the "winingNumbers" field.
thanks
========================================
-----Original Message-----
From: Mahler Thomas [mailto:[EMAIL PROTECTED]]
Sent: Mon 1/20/2003 7:33 AM
To: 'OJB Users List'
Cc:
Subject: AW: How to represent a collection of objects in OJB
sure, why not?
if you don't have a collection-descriptor for a given
attribute, it won't be
persisted to the db.
You can fill the workstations attribute with
broker.getCollectionByQuery(...)
cheers,
Thomas
> -----Urspr�ngliche Nachricht-----
> Von: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
> Gesendet: Montag, 20. Januar 2003 16:31
> An: [EMAIL PROTECTED]
> Betreff: RE: How to represent a collection of
objects in OJB
>
>
> Hi Thomas,
>
> With your solution you store the collection
"workstations" in
> the database, right?
> In fact I don't need to store this collection
because it's a
> dynamic result of a query to the Workstation table.
>
> Is there a solution without using the database?
>
> Regards
> Sylvain
>
>
> -----Message d'origine-----
> De: Mahler Thomas
[mailto:[EMAIL PROTECTED]]
> Date: lundi, 20. janvier 2003 15:16
> �: 'OJB Users List'
> Objet: RE: How to represent a collection of objects
in OJB
>
>
> Hi,
>
> > Hello,
> >
> > I'm using OJB and I'm asking something:
> >
> > I have a class called Workstation that represent a
> > workstation. There is a table "Workstation" in the
database
> > and OJB provides the link between.
> >
> > My question is:
> > I need to represent a collection (or a Node) of
workstations
> > in the class Workstation because I use this class
as a model
> > in a MVC environment.
> > Is it possible?
>
> Yes. OJB can handle such reursive associations
without problems.
>
> > How to do that without causing problem in the
mapping?
>
> 1. add a collection attribute "workstations" to the
class Workstation
> this collection will hold the associated
workstations.
>
> 2. you have to decide wether this assosciation is
1:n or m:n.
> for 1:n you just need an additional foreignkey
attribute in
> the WORKSTATION
> table.
> Of course you'll also need a matching attribute in
the class
> Workstation.
>
> For a m:n association you'll have to define a
intermediary
> table to hold the
> mapping entries.
>
> 3. define a collection-descriptor in repository.xml.
> Follow the steps in tutorial3.html on 1:n and m:n.
>
>
> cheers,
> Thomas
>
>
> >
> > Thank you
> > Sylvain
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>