public PersistenceElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) { super(member, pd); PersistenceContext pc = ae.getAnnotation(PersistenceContext.class); PersistenceUnit pu = ae.getAnnotation(PersistenceUnit.class); Class<?> resourceType = EntityManager.class; if (pc != null) { if (pu != null) { throw new IllegalStateException("Member may only be annotated with either " + "@PersistenceContext or @PersistenceUnit, not both: " + member); } Properties properties = null; PersistenceProperty[] pps = pc.properties(); if (!ObjectUtils.isEmpty(pps)) { properties = new Properties(); for (PersistenceProperty pp : pps) { properties.setProperty(pp.name(), pp.value()); } } this.unitName = pc.unitName(); this.type = pc.type(); this.synchronizedWithTransaction = SynchronizationType.SYNCHRONIZED.equals(pc.synchronization()); this.properties = properties; } else { resourceType = EntityManagerFactory.class; this.unitName = pu.unitName(); } checkResourceType(resourceType); }
public PersistenceElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) { super(member, pd); PersistenceContext pc = ae.getAnnotation(PersistenceContext.class); PersistenceUnit pu = ae.getAnnotation(PersistenceUnit.class); Class<?> resourceType = EntityManager.class; if (pc != null) { if (pu != null) { throw new IllegalStateException("Member may only be annotated with either " + "@PersistenceContext or @PersistenceUnit, not both: " + member); } Properties properties = null; PersistenceProperty[] pps = pc.properties(); if (!ObjectUtils.isEmpty(pps)) { properties = new Properties(); for (PersistenceProperty pp : pps) { properties.setProperty(pp.name(), pp.value()); } } this.unitName = pc.unitName(); this.type = pc.type(); this.synchronizedWithTransaction = SynchronizationType.SYNCHRONIZED.equals(pc.synchronization()); this.properties = properties; } else { resourceType = EntityManagerFactory.class; this.unitName = pu.unitName(); } checkResourceType(resourceType); }
public PersistenceElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) { super(member, pd); PersistenceContext pc = ae.getAnnotation(PersistenceContext.class); PersistenceUnit pu = ae.getAnnotation(PersistenceUnit.class); Class<?> resourceType = EntityManager.class; if (pc != null) { if (pu != null) { throw new IllegalStateException("Member may only be annotated with either " + "@PersistenceContext or @PersistenceUnit, not both: " + member); } Properties properties = null; PersistenceProperty[] pps = pc.properties(); if (!ObjectUtils.isEmpty(pps)) { properties = new Properties(); for (PersistenceProperty pp : pps) { properties.setProperty(pp.name(), pp.value()); } } this.unitName = pc.unitName(); this.type = pc.type(); this.synchronizedWithTransaction = SynchronizationType.SYNCHRONIZED.equals(pc.synchronization()); this.properties = properties; } else { resourceType = EntityManagerFactory.class; this.unitName = pu.unitName(); } checkResourceType(resourceType); }