37 lines
955 B
Java
Raw Normal View History

2015-04-12 23:49:00 +03:00
package com.iluwatar;
import java.util.List;
2015-04-13 21:22:03 +03:00
public class App {
public static void main( String[] args ) {
WizardDao dao = new WizardDao();
persistData(dao);
queryData(dao);
}
public static void persistData(WizardDao dao) {
Spell spell = new Spell("Fireball");
Spellbook spellbook = new Spellbook("Book of fire");
spell.setSpellbook(spellbook);
2015-04-13 21:22:03 +03:00
spellbook.getSpells().add(spell);
Wizard wizard = new Wizard("Jugga");
spellbook.setWizard(wizard);
2015-04-13 21:22:03 +03:00
wizard.getSpellbooks().add(spellbook);
dao.persist(wizard);
}
public static void queryData(WizardDao dao) {
List<Wizard> wizards = dao.findAll();
for (Wizard w: wizards) {
System.out.println(w);
for (Spellbook spellbook: w.getSpellbooks()) {
System.out.println(spellbook);
for (Spell spell: spellbook.getSpells()) {
System.out.println(spell);
}
}
2015-04-13 21:22:03 +03:00
}
2015-04-12 23:49:00 +03:00
}
}