Package com.umbrella.webapp.biz

Source Code of com.umbrella.webapp.biz.StudentManager

package com.umbrella.webapp.biz;

import com.umbrella.webapp.entity.Student;
import javax.annotation.PostConstruct;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;

/**
*
* @author d.traverso
*/
public class StudentManager {
   
    @PersistenceUnit(unitName = "cassandra_pu")
    private EntityManagerFactory entityManagerFactory;
    private EntityManager em;

    public StudentManager() {
    }

    @PostConstruct
    public void init() {
        em = entityManagerFactory.createEntityManager();
    }

    public Student getDefaultStudent() {
        Student defaultStudent = new Student();
        defaultStudent.setName("Default Student");
        return defaultStudent;
    }

    public Student getStudent(Long id) {
        return em.find(Student.class, id);
    }

    public void createStudent(Student student) {
        em.persist(student);
    }   
}
TOP

Related Classes of com.umbrella.webapp.biz.StudentManager

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.