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");
|
2015-04-13 22:08:01 +03:00
|
|
|
spell.setSpellbook(spellbook);
|
2015-04-13 21:22:03 +03:00
|
|
|
spellbook.getSpells().add(spell);
|
|
|
|
Wizard wizard = new Wizard("Jugga");
|
2015-04-13 22:08:01 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|