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() {
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface MagicService {
|
||||
|
||||
List<Wizard> findAllWizards();
|
||||
|
||||
List<Spellbook> findAllSpellbooks();
|
||||
|
||||
List<Spell> findAllSpells();
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,31 @@
|
||||
package com.iluwatar;
|
||||
|
||||
public class MagicServiceImpl implements MagicService {
|
||||
import java.util.List;
|
||||
|
||||
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)
|
||||
private Set<Spellbook> spellbooks;
|
||||
|
||||
public String getFirstName() {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.name = firstName;
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Set<Spellbook> getSpellbooks() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user