30 lines
771 B
Java
Raw Normal View History

2015-04-12 23:49:00 +03:00
package com.iluwatar;
2015-04-13 21:22:03 +03:00
public class App {
public static void main( String[] args ) {
2015-04-13 22:36:52 +03:00
WizardDaoImpl dao = new WizardDaoImpl();
2015-04-13 21:22:03 +03:00
persistData(dao);
2015-04-13 22:36:52 +03:00
queryData();
2015-04-13 21:22:03 +03:00
}
2015-04-13 22:36:52 +03:00
public static void persistData(WizardDaoImpl dao) {
2015-04-13 21:22:03 +03:00
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);
}
2015-04-13 22:36:52 +03:00
public static void queryData() {
MagicService magicService = new MagicServiceImpl();
for (Wizard w: magicService.findAllWizards()) {
2015-04-13 21:22:03 +03:00
System.out.println(w);
}
2015-04-12 23:49:00 +03:00
}
}