Package javax.persistence

Examples of javax.persistence.PersistenceContext.unitName()


    Boolean faultFound = false;
    for (Field field : declaredFields) {
      PersistenceContext annotation = field.getAnnotation(PersistenceContext.class);
      if (annotation == null)
        continue;
      final String unitName = annotation.unitName();
      if (unitName.isEmpty()) {
        System.err.println("Field [" + field.getName() + "] annotated with PersistenceContext must specify unitName");
        faultFound = true;
      }
View Full Code Here


  private ArrayList<EntityManager> createAndInjectEntityManagers(ArrayList<Field> fields) {
    ArrayList<EntityManager> managers = new ArrayList<EntityManager>();
    for (Field field : fields) {
      try {
        PersistenceContext annotation = field.getAnnotation(PersistenceContext.class);
        EntityManager entityManager = Persistence.createEntityManagerFactory(annotation.unitName()).createEntityManager();
        boolean accessible = field.isAccessible();
        field.setAccessible(true);
        field.set(testClass, entityManager);
        field.setAccessible(accessible);
        managers.add(entityManager);
View Full Code Here

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.