Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reference to element in list

 
Alex Avb
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

Please, help with the following problem.
I have object A, that contains a List of String elements (I use List because I need an order of this Strings). In object B I want to have a field, that refers to element in this List on some position (I mean, B has String field, that contains String object from List on some position). Is it posible?

I have the following:

class A {
private List values = new ArrayList(); //contains Strings

/**
* @hibernate.list table="Values" cascade="all"
* @hibernate.collection-key column="A_ID"
* @hibernate.collection-index column="index"
* @hibernate.collection-element column="value" type="java.lang.String"
*/
public List getValues() {
return values;
}
...
}

class B {
private String value;

//What should I put here??
public String getValue() {
return value;
}
}

There is composite foreign key, that consist of index and A_ID.. I don't know how to solve it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic