try { InputStream is = Thread.currentThread().getContextClassLoader( ).getResource("META-INF/persistence.xml").openStream(); FileOutputStream output= new FileOutputStream("c:/tmp/show.xml"); IOUtils.copy(is, output); IOUtils.closeQuietly(output); PersistenceUnitInfoImpl impl= new PersistenceUnitInfoImpl(); impl.setPersistenceXmlFileUrl(new URL("file://c:/tmp/show.xml")); JpaBasics basics= new JpaBasics("spektrum"); basics.init(false); EntityManager em= basics.getEm(); _log.debug("have we an em: " + em); new TestLoad().testLoadMagazines(); } catch (Exception e) { _log.error("", e); } }
/** * Parse persistence-unit element. */ private void startPersistenceUnit(Attributes attrs) throws SAXException { _info = new PersistenceUnitInfoImpl(); _info.setPersistenceUnitName(attrs.getValue("name")); // we only parse this ourselves outside a container, so default // transaction type to local String val = attrs.getValue("transaction-type"); if (val == null) _info.setTransactionType (PersistenceUnitTransactionType.RESOURCE_LOCAL); else _info.setTransactionType(Enum.valueOf (PersistenceUnitTransactionType.class, val)); if (_source != null) _info.setPersistenceXmlFileUrl(_source); } }
/** * Parse persistence-unit element. */ private void startPersistenceUnit(Attributes attrs) throws SAXException { _excludeUnlistedSet = false; _info = new PersistenceUnitInfoImpl(); _info.setPersistenceUnitName(attrs.getValue("name")); _info.setPersistenceXMLSchemaVersion(_persistenceVersion); // we only parse this ourselves outside a container, so default // transaction type to local String val = attrs.getValue("transaction-type"); if (val == null) _info.setTransactionType(PersistenceUnitTransactionType.RESOURCE_LOCAL); else _info.setTransactionType(Enum.valueOf(PersistenceUnitTransactionType.class, val)); if (_source != null) _info.setPersistenceXmlFileUrl(_source); }
/** * Parse persistence-unit element. */ private void startPersistenceUnit(Attributes attrs) throws SAXException { _excludeUnlistedSet = false; _info = new PersistenceUnitInfoImpl(); _info.setPersistenceUnitName(attrs.getValue("name")); _info.setPersistenceXMLSchemaVersion(_persistenceVersion); // we only parse this ourselves outside a container, so default // transaction type to local String val = attrs.getValue("transaction-type"); if (val == null) _info.setTransactionType(PersistenceUnitTransactionType.RESOURCE_LOCAL); else _info.setTransactionType(Enum.valueOf(PersistenceUnitTransactionType.class, val)); if (_source != null) _info.setPersistenceXmlFileUrl(_source); }
/** * Parse persistence-unit element. */ private void startPersistenceUnit(Attributes attrs) throws SAXException { _excludeUnlistedSet = false; _info = new PersistenceUnitInfoImpl(); _info.setPersistenceUnitName(attrs.getValue("name")); _info.setPersistenceXMLSchemaVersion(_persistenceVersion); // we only parse this ourselves outside a container, so default // transaction type to local String val = attrs.getValue("transaction-type"); if (val == null) _info.setTransactionType(PersistenceUnitTransactionType.RESOURCE_LOCAL); else _info.setTransactionType(Enum.valueOf(PersistenceUnitTransactionType.class, val)); if (_source != null) _info.setPersistenceXmlFileUrl(_source); }
/** * Parse persistence-unit element. */ private void startPersistenceUnit(Attributes attrs) throws SAXException { _excludeUnlistedSet = false; _info = new PersistenceUnitInfoImpl(); _info.setPersistenceUnitName(attrs.getValue("name")); _info.setPersistenceXMLSchemaVersion(_persistenceVersion); // we only parse this ourselves outside a container, so default // transaction type to local String val = attrs.getValue("transaction-type"); if (val == null) _info.setTransactionType(PersistenceUnitTransactionType.RESOURCE_LOCAL); else _info.setTransactionType(Enum.valueOf(PersistenceUnitTransactionType.class, val)); if (_source != null) _info.setPersistenceXmlFileUrl(_source); }