I don't think that you will succeed in mapping an ArrayList of Strings
without creating a new class. If you don't create that new class, Castor
will not be able to defer identity information for this class whic is
required when traversing the one-to-many relation.
Werner
Ander Garcia Gangoiti wrote:
> Dear all
>
> I am trying to create the mapping for a class that contains an ArrayList of
> strings. I have created a table that has, for each of the values of the
> arraylist, a primary key, a foreign key to the table of the main class and a
> varchar field to store the value of the string.
>
> The examples I have found about one-to-may relations are more "advanced",
> they create a new class and they use the mapping of this class to map the
> one-to-may relations.
>
> But for "simpler" cases like this, where you only have an ArrayList of type
> string and there is no additional class, what can I do? Can I keep my one
> class -two tables structure? How? Have I to modified it?
>
> Thank you very much in advance
>
> More detailed description
> -------------------------
>
> In my case I have some users that prefer some keywords. The UserPreferences
> class has an Arraylist of keywords prefered by users. There is a table for
> UserPreferences and another one for each of the Keywords prefered by each
> user.
>
>
> This is the Java class:
>
> public class UserPreferences {
>
> private int _id;
> private ArrayList<String> _keywords = new ArrayList<String>();
>
> //id
> public int getId(
> ) {
> return this._id;
> }
> public void setId(
> final int id) {
> this._id = id;
> }
> // keywords
> public java.util.ArrayList<String> getKeywords(
> ) {
> return this._keywords;
> }
> public void setKeywords(
> final java.util.ArrayList<String> keywords) {
> this._keywords = keywords;
> }
> }
>
> This are the tables:
>
> -USERPREFERENCES:
> -IdUserPreferences (Integer,PK)
>
> -KEYWORD:
> -IdKeyWord (Integer,PK)
> -IdUserPreferences (Integer,FK)
> -Keyword (VARCHAR)
>
> I have no mapping file because I am not able to get a valid one for this
> case
>
> Best regards
>
> Ander Garcia
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
> http://xircles.codehaus.org/manage_email
>
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email