Q:

Updating entity through JPA

I am doing a project for self-education and have stuck with a problem when I am trying to update an entity that is bound to the other entity.
I am using Spring Boot 1.2.3.RELEASE + jpa.
Person:
@Component
@Entity
@Table(name = "Person_sql", uniqueConstraints = 
       @UniqueConstraint(columnNames = {"name", "passport"}))

public class Person implements AcademyEntity {

@Id
@GeneratedValue
private long id;

private String name;
private Date birthday;
@Column(unique=true)
private String passport;

@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "person_id")
private Set<Teacher> teacherSet;

public Person() {
    this.birthday = new Date();
    studentSet = new HashSet<Student>();
    teacherSet = new HashSet<Teacher>();
}

public Person(String name, Date birthday, String passport) {
    this.name = name;
    this.birthday = birthday;
    this.passport = passport;
    studentSet = new HashSet<Student>();
    teacherSet = new HashSet<Teacher>();
}

getters, setters, equals, hashCode, toString
}

Teacher
@Component
@Entity
@Table(name = "Teacher_sql")

public class Teacher implements AcademyEntity {

@Id
@GeneratedValue
private long id;
private Date start;
private Date finish;

@ManyToOne
@JoinColumn(nullable = false)
private Person person;

... constructors, getters, setters, equals, hashCode, toString
}

JPAPersonDAO
public interface JPAPersonDAO extends JpaRepository<Person, Long> {
}

JPAPersonService
@Service
public class JPAPersonService implements PersonService {
private JPAPersonDAO jpaPersonDAO;
...
@Override
public boolean saveService(Object object) {
    if (object instanceof Person) {
        try {
            if (validatePerson((Person) object)) {
                jpaPersonDAO.save((Person) object);
                return true;
            }
        } catch (RuntimeException e) {
            log.error(e);
        }
    }
    return false;
}
...

When I'm updating person that is not a teacher - all is fine. If I touch a person that is a teacher - I get this error:
Person person = new Person();
person.setId(..);
jpaPersonService.saveService(person);
...
WARN 6308 --- [nio-8181-exec-6] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 23502, SQLState: 23502
ERROR 6308 --- [nio-8181-exec-6] o.h.engine.jdbc.spi.SqlExceptionHelper   : NULL not allowed for column "PERSON_ID"; SQL statement
NULL not allowed for column "PERSON_ID"; SQL statement: update teacher_sql set person_id=null where person_id=? [23502-185]
INFO 6308 --- [nio-8181-exec-6] o.h.e.j.b.internal.AbstractBatchImpl     : HHH000010: On release of batch it still contained JDBC statements

I assume that I might use transactions (@Transactional) here, but I don't understand 'how-to'.
Thanks for any help!
EDIT
If I use pure hibernate (without spring and jpa) with the same entities it works fine.
public class HibernatePersonDAOImpl implements PersonDAO {
...
private boolean saveOrDelete(Person p, boolean delete) {
    Session session = hibernateUtils.getSession();
    try {
        Transaction t = session.beginTransaction();
        if (delete) {
            session.delete(p);
        } else {
            session.merge(p);
        }
        t.commit();
    } catch (HibernateException e) {
        e.printStackTrace();
        return false;
    }
    return true;
}

A:

I believe you are missing the mappedBy parameter on one of your relations.
@OneToMany(cascade = CascadeType.ALL, mappedBy="person")
private Set<Teacher> teacherSet;

