Added findAll methods to service level.
This commit is contained in:
parent
281f225a54
commit
3d3828933c
@ -113,5 +113,18 @@ public class App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void queryData() {
|
public static void queryData() {
|
||||||
|
MagicService service = new MagicServiceImpl(new WizardDaoImpl(), new SpellbookDaoImpl(), new SpellDaoImpl());
|
||||||
|
System.out.println("Enumerating all wizards");
|
||||||
|
for (Wizard w: service.findAllWizards()) {
|
||||||
|
System.out.println(w.getName());
|
||||||
|
}
|
||||||
|
System.out.println("Enumerating all spellbooks");
|
||||||
|
for (Spellbook s: service.findAllSpellbooks()) {
|
||||||
|
System.out.println(s.getName());
|
||||||
|
}
|
||||||
|
System.out.println("Enumerating all spells");
|
||||||
|
for (Spell s: service.findAllSpells()) {
|
||||||
|
System.out.println(s.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public interface MagicService {
|
public interface MagicService {
|
||||||
|
|
||||||
|
List<Wizard> findAllWizards();
|
||||||
|
|
||||||
|
List<Spellbook> findAllSpellbooks();
|
||||||
|
|
||||||
|
List<Spell> findAllSpells();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,31 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MagicServiceImpl implements MagicService {
|
public class MagicServiceImpl implements MagicService {
|
||||||
|
|
||||||
|
private WizardDao wizardDao;
|
||||||
|
private SpellbookDao spellbookDao;
|
||||||
|
private SpellDao spellDao;
|
||||||
|
|
||||||
|
public MagicServiceImpl(WizardDao wizardDao, SpellbookDao spellbookDao, SpellDao spellDao) {
|
||||||
|
this.wizardDao = wizardDao;
|
||||||
|
this.spellbookDao = spellbookDao;
|
||||||
|
this.spellDao = spellDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Wizard> findAllWizards() {
|
||||||
|
return wizardDao.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Spellbook> findAllSpellbooks() {
|
||||||
|
return spellbookDao.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Spell> findAllSpells() {
|
||||||
|
return spellDao.findAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,12 +42,12 @@ public class Wizard extends BaseEntity {
|
|||||||
@ManyToMany(cascade = CascadeType.ALL)
|
@ManyToMany(cascade = CascadeType.ALL)
|
||||||
private Set<Spellbook> spellbooks;
|
private Set<Spellbook> spellbooks;
|
||||||
|
|
||||||
public String getFirstName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFirstName(String firstName) {
|
public void setName(String name) {
|
||||||
this.name = firstName;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Spellbook> getSpellbooks() {
|
public Set<Spellbook> getSpellbooks() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user