/** * Set a persistence unit root location for the default persistence unit. * <p>Default is "classpath:", that is, the root of the current classpath * (nearest root directory). To be overridden if unit-specific resolution * does not work and the classpath root is not appropriate either. * <p><b>NOTE: Only applied if no external PersistenceUnitManager specified.</b> * @since 4.3.3 * @see DefaultPersistenceUnitManager#setDefaultPersistenceUnitRootLocation */ public void setPersistenceUnitRootLocation(String defaultPersistenceUnitRootLocation) { this.internalPersistenceUnitManager.setDefaultPersistenceUnitRootLocation(defaultPersistenceUnitRootLocation); }
/** * Set a persistence unit root location for the default persistence unit. * <p>Default is "classpath:", that is, the root of the current classpath * (nearest root directory). To be overridden if unit-specific resolution * does not work and the classpath root is not appropriate either. * <p><b>NOTE: Only applied if no external PersistenceUnitManager specified.</b> * @since 4.3.3 * @see DefaultPersistenceUnitManager#setDefaultPersistenceUnitRootLocation */ public void setPersistenceUnitRootLocation(String defaultPersistenceUnitRootLocation) { this.internalPersistenceUnitManager.setDefaultPersistenceUnitRootLocation(defaultPersistenceUnitRootLocation); }
/** * Set a persistence unit root location for the default persistence unit. * <p>Default is "classpath:", that is, the root of the current classpath * (nearest root directory). To be overridden if unit-specific resolution * does not work and the classpath root is not appropriate either. * <p><b>NOTE: Only applied if no external PersistenceUnitManager specified.</b> * @since 4.3.3 * @see DefaultPersistenceUnitManager#setDefaultPersistenceUnitRootLocation */ public void setPersistenceUnitRootLocation(String defaultPersistenceUnitRootLocation) { this.internalPersistenceUnitManager.setDefaultPersistenceUnitRootLocation(defaultPersistenceUnitRootLocation); }
f.setAccessible(true); DefaultPersistenceUnitManager m = (DefaultPersistenceUnitManager)f.get(em); m.setDefaultPersistenceUnitRootLocation(null); } catch (Exception e) { e.printStackTrace();
@Override protected EntityManagerFactory createEntityManagerFactory() { DefaultPersistenceUnitManager internalPersistenceUnitManager = new DefaultPersistenceUnitManager(); internalPersistenceUnitManager.setPersistenceXmlLocation(getHibernateConnection().getPath()); internalPersistenceUnitManager.setDefaultPersistenceUnitRootLocation(null); internalPersistenceUnitManager.preparePersistenceUnitInfos(); PersistenceUnitInfo persistenceUnitInfo = internalPersistenceUnitManager.obtainDefaultPersistenceUnitInfo(); EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(persistenceUnitInfo, Collections.emptyMap()); return builder.build(); }
private void performDllGeneration() throws MalformedURLException { for (String eachDatabaseProductName : this.databaseProductNames) { String[] allBasePackages = this.getBasePackages(); this.logger.info("Using base packages " + Joiner.on(", ").join(allBasePackages)); final PersistenceProvider provider = new PersistenceProvider(); final DefaultPersistenceUnitManager manager = new DefaultPersistenceUnitManager(); manager.setDefaultPersistenceUnitRootLocation(null); manager.setDefaultPersistenceUnitName("default"); manager.setPackagesToScan(allBasePackages); manager.setPersistenceXmlLocations(new String[0]); manager.afterPropertiesSet(); final MutablePersistenceUnitInfo puInfo = (MutablePersistenceUnitInfo) manager.obtainDefaultPersistenceUnitInfo(); puInfo.setPersistenceProviderPackageName(provider.getClass().getName()); puInfo.setPersistenceUnitRootUrl(new URL("http://foo.bar")); this.logger.info("Managed classes found: " + puInfo.getManagedClassNames().size()); this.logger.debug("Managed class names:\n -> " + Joiner.on("\n -> ").join(puInfo.getManagedClassNames())); final Map<String, Object> properties = this.buildProperties(eachDatabaseProductName); puInfo.getProperties().putAll(properties); provider.generateSchema(puInfo, properties); } } }