jeudi 9 avril 2015

Store an Object that has a List

First of all, sorry for the very strange question title, I couldn't figure out a better way to word it!


So I have an Object as follows, it has a String for the name of the exercise (saves duplication inside the List), and the List of Set Objects, each set has a weight(double) and a number of reps(int).



public class Card implements Serializable {
public String name;
List<Set> sets;

public Card(String name) {
this.name = name;
sets = new ArrayList<>();
}

public String getName() {
return name;
}

public List<Set> getSet() {
return sets;
}

public void addSet(Set s) {
sets.add(s);
}

public String toString(){
return "Name: " + name + ", Set: " + sets.toString();
}}


Now I want to store this inside of a database. How would I go about achieving this, because I know I cant store a List inside a database unless I give it its own table, but each member of the list has a name which is the String name, and this name would come up multiple times in the database, so it isnt unique to just this set of sets (sorry about the wording!! :P ) Hopefully one of you can decipher my poorly worded question and explanation and provide me with an answer :) need anymore info, just leave a comment!


Aucun commentaire:

Enregistrer un commentaire