Java Code Examples for javax.persistence.PersistenceUnit#unitName()
The following examples show how to use
javax.persistence.PersistenceUnit#unitName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicJpaInjectionServices.java From hammock with Apache License 2.0 | 5 votes |
@Override public ResourceReferenceFactory<EntityManagerFactory> registerPersistenceUnitInjectionPoint(InjectionPoint ip) { PersistenceUnit pc = ip.getAnnotated().getAnnotation(PersistenceUnit.class); if (pc == null) { throw new IllegalArgumentException("No @PersistenceUnit annotation found on EntityManagerFactory"); } String name = pc.unitName(); LOG.info("Creating EntityManagerFactoryReferenceFactory for unit " + name); return new EntityManagerFactoryReferenceFactory(name); }
Example 2
Source File: JpaService.java From kumuluzee with MIT License | 4 votes |
@Override public ResourceReferenceFactory<EntityManagerFactory> registerPersistenceUnitInjectionPoint (InjectionPoint injectionPoint) { PersistenceUnitHolder holder = PersistenceUnitHolder.getInstance(); PersistenceUnit pu = injectionPoint.getAnnotated().getAnnotation(PersistenceUnit.class); String unitName = pu.unitName(); if (unitName.isEmpty()) { unitName = holder.getDefaultUnitName(); if (unitName.isEmpty()) { throw new NoDefaultPersistenceUnit(); } } PersistenceWrapper wrapper = holder.getEntityManagerFactory(unitName); return new PersistenceUnitResourceFactory(wrapper.getEntityManagerFactory()); }