|
|
|
@ -1,10 +1,15 @@ |
|
|
|
package de.kreth.vaadin.clubhelper.vaadinclubhelper.dao; |
|
|
|
package de.kreth.vaadin.clubhelper.vaadinclubhelper.dao; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import javax.persistence.TypedQuery; |
|
|
|
import javax.persistence.TypedQuery; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Repository; |
|
|
|
import org.springframework.stereotype.Repository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Contact; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.EntityAccessor; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Startpass; |
|
|
|
|
|
|
|
|
|
|
|
@Repository |
|
|
|
@Repository |
|
|
|
public class PersonDaoImpl extends AbstractDaoImpl<Person> implements PersonDao { |
|
|
|
public class PersonDaoImpl extends AbstractDaoImpl<Person> implements PersonDao { |
|
|
|
@ -13,6 +18,31 @@ public class PersonDaoImpl extends AbstractDaoImpl<Person> implements PersonDao |
|
|
|
super(Person.class); |
|
|
|
super(Person.class); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void save(Person obj) { |
|
|
|
|
|
|
|
checkSubEntities(obj); |
|
|
|
|
|
|
|
super.save(obj); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void checkSubEntities(Person obj) { |
|
|
|
|
|
|
|
Startpass startPass = obj.getStartpass(); |
|
|
|
|
|
|
|
if (startPass != null && startPass.hasValidId() == false) { |
|
|
|
|
|
|
|
persistIfNew(startPass); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<Contact> contacts = obj.getContacts(); |
|
|
|
|
|
|
|
if (contacts != null) { |
|
|
|
|
|
|
|
for (Contact c : contacts) { |
|
|
|
|
|
|
|
persistIfNew(c); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void persistIfNew(EntityAccessor c) { |
|
|
|
|
|
|
|
if (c.hasValidId() == false) { |
|
|
|
|
|
|
|
entityManager.persist(c); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Person findLoginUser(String username, String password) { |
|
|
|
public Person findLoginUser(String username, String password) { |
|
|
|
TypedQuery<Person> query = entityManager.createNamedQuery(Person.QUERY_FINDLOGIN, Person.class); |
|
|
|
TypedQuery<Person> query = entityManager.createNamedQuery(Person.QUERY_FINDLOGIN, Person.class); |
|
|
|
|