docs: update service layer

This commit is contained in:
Ilkka Seppälä
2024-05-20 13:03:23 +03:00
parent 2a789cf65a
commit d656295d3c
6 changed files with 181 additions and 208 deletions
@@ -93,7 +93,7 @@ public abstract class DaoBaseImpl<E extends BaseEntity> implements Dao<E> {
@Override
public E merge(E entity) {
Transaction tx = null;
E result = null;
E result;
try (var session = getSessionFactory().openSession()) {
tx = session.beginTransaction();
result = (E) session.merge(entity);
@@ -33,12 +33,16 @@ import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import lombok.Getter;
import lombok.Setter;
/**
* Spell entity.
*/
@Entity
@Table(name = "SPELL")
@Getter
@Setter
public class Spell extends BaseEntity {
private String name;
@@ -60,30 +64,6 @@ public class Spell extends BaseEntity {
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Spellbook getSpellbook() {
return spellbook;
}
public void setSpellbook(Spellbook spellbook) {
this.spellbook = spellbook;
}
@Override
public String toString() {
return name;
@@ -38,12 +38,16 @@ import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import lombok.Getter;
import lombok.Setter;
/**
* Spellbook entity.
*/
@Entity
@Table(name = "SPELLBOOK")
@Getter
@Setter
public class Spellbook extends BaseEntity {
@Id
@@ -69,38 +73,6 @@ public class Spellbook extends BaseEntity {
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<Wizard> getWizards() {
return wizards;
}
public void setWizards(Set<Wizard> wizards) {
this.wizards = wizards;
}
public Set<Spell> getSpells() {
return spells;
}
public void setSpells(Set<Spell> spells) {
this.spells = spells;
}
public void addSpell(Spell spell) {
spell.setSpellbook(this);
spells.add(spell);
@@ -35,12 +35,16 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import lombok.Getter;
import lombok.Setter;
/**
* Wizard entity.
*/
@Entity
@Table(name = "WIZARD")
@Getter
@Setter
public class Wizard extends BaseEntity {
@Id
@@ -62,30 +66,6 @@ public class Wizard extends BaseEntity {
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<Spellbook> getSpellbooks() {
return spellbooks;
}
public void setSpellbooks(Set<Spellbook> spellbooks) {
this.spellbooks = spellbooks;
}
public void addSpellbook(Spellbook spellbook) {
spellbook.getWizards().add(this);
spellbooks.add(spellbook);
@@ -122,7 +122,7 @@ class MagicServiceImplTest {
}
@Test
void testFindWizardsWithSpell() throws Exception {
void testFindWizardsWithSpell() {
final var wizards = Set.of(
mock(Wizard.class),
mock(Wizard.class),