DataNucleus 3.0與Hibernate 3.5

如官方產品站點所述, DataNucleus Access Platform是現有的最符合標準的開源Java持久性產品。 它完全符合JDO1 , JDO2 , JDO2.1 , JDO2.2 , JDO3 , JPA1和JPA2 Java標準。 它還符合OGC簡單功能規范,以將地理空間Java類型保留到RDBMS。 它使用基于OSGi的插件機制,這意味著它是非常可擴展的。

如產品官方“關于”頁面所述, Hibernate是一種高性能的對象/關系持久性和查詢服務。 Hibernate是市場上最靈活,功能最強大的對象/關系解決方案,它負責從Java類到數據庫表以及從Java數據類型到SQL數據類型的映射。 它提供了數據查詢和檢索功能,大大減少了開發時間。

出于本文的目的,我們將使用上述眾所周知的產品作為持久性API的實際實現。 我們的目標是能夠比較對數據庫應用CRUD(創建-檢索-更新-刪除)操作時的性能。

為此,我們將實現兩個不同的基于Spring的WEB應用程序,這些應用程序將充當我們的“測試基礎”。 這兩個應用程序的服務和數據訪問層定義(接口和實現類)將完全相同。 對于數據訪問,我們將利用JPA2作為Java Persistence API。 對于數據庫,我們將使用嵌入式Derby實例。 最后但并非最不重要的一點是,我們將針對以下所述的五個“基本”數據訪問操作實施并執行相同的性能測試:

  • 保持記錄
  • 通過其ID檢索記錄
  • 檢索所有記錄
  • 更新現有記錄
  • 刪除記錄

所有測試均針對具有以下特征的Sony Vaio進行:

  • 系統:openSUSE 11.1(x86_64)
  • 處理器(CPU):Intel(R)Core(TM)2 Duo CPU T6670 @ 2.20GHz
  • 處理器速度:1,200.00 MHz
  • 總內存(RAM):2.8 GB
  • Java:OpenJDK 1.6.0_0 64位

使用以下工具:

  • Spring框架3.0.1
  • Apache Derby 10.6.1.0
  • 休眠 3.5.1
  • DataNucleus 3.0.0-m1
  • c3p0 0.9.1.2
  • Brent Boyer的Java Benchmarking框架

最終通知:

  • 您可以在此處和此處下載兩個“測試基礎”的完整源代碼。 這些是基于Eclipse – Maven的項目。
  • 為了能夠自己編譯和運行測試,您需要將Java Benchmarking框架二進制– jar文件安裝到Maven存儲庫。 另外,作為“一鍵式”解決方案,您可以使用我們創建的Java Benchmarking Maven軟件包。 您可以從此處下載它,然后將其解壓縮到您的Maven存儲庫中,一切都很好。

“測試基地”…

我們將首先提供有關如何實施“測試基礎”項目的信息。 為了使我們的測試所針對的環境的細節清晰明了,這勢在必行。 如前所述,我們已經實現了兩個基于Spring的多層WEB應用程序。 在每個應用程序中,已經實現了兩層,即服務層和數據訪問層。 這些層具有相同的定義-接口和實現細節。

我們的領域模型僅包含一個“雇員”對象。 服務層提供了一個簡單的“業務”服務,該服務公開了“員工”對象的CRUD(創建-檢索-更新-刪除)功能,而數據訪問層則包括一個簡單的數據訪問對象,該對象利用Spring JpaDaoSupport抽象來提供與數據庫的實際互操作性。

以下是數據訪問層特定的類:

import javax.annotation.PostConstruct;
import javax.persistence.EntityManagerFactory;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;import com.javacodegeeks.springdatanucleus.dto.EmployeeDTO;@Repository("employeeDAO")
public class EmployeeDAO extends JpaDAO<Long, EmployeeDTO> {@AutowiredEntityManagerFactory entityManagerFactory;@PostConstructpublic void init() {super.setEntityManagerFactory(entityManagerFactory);}}

如您所見,我們的數據訪問對象(DAO)擴展了JpaDAO類。 該課程如下:

import java.lang.reflect.ParameterizedType;
import java.util.List;import javax.persistence.EntityManager;
import javax.persistence.PersistenceException;
import javax.persistence.Query;import org.springframework.orm.jpa.JpaCallback;
import org.springframework.orm.jpa.support.JpaDaoSupport;public abstract class JpaDAO<K, E> extends JpaDaoSupport {protected Class<E> entityClass;@SuppressWarnings("unchecked")public JpaDAO() {ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass();this.entityClass = (Class<E>) genericSuperclass.getActualTypeArguments()[1];}public void persist(E entity) {getJpaTemplate().persist(entity);}public void remove(E entity) {getJpaTemplate().remove(entity);}public E merge(E entity) {return getJpaTemplate().merge(entity);}public void refresh(E entity) {getJpaTemplate().refresh(entity);}public E findById(K id) {return getJpaTemplate().find(entityClass, id);}public E flush(E entity) {getJpaTemplate().flush();return entity;}@SuppressWarnings("unchecked")public List<E> findAll() {Object res = getJpaTemplate().execute(new JpaCallback() {public Object doInJpa(EntityManager em) throws PersistenceException {Query q = em.createQuery("SELECT h FROM " +entityClass.getName() + " h");return q.getResultList();}});return (List<E>) res;}@SuppressWarnings("unchecked")public Integer removeAll() {return (Integer) getJpaTemplate().execute(new JpaCallback() {public Object doInJpa(EntityManager em) throws PersistenceException {Query q = em.createQuery("DELETE FROM " +entityClass.getName() + " h");return q.executeUpdate();}});}}

以下是我們的域類EmployeeDTO類:

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;@Entity
@Table(name = "EMPLOYEE")
public class EmployeeDTO implements java.io.Serializable {private static final long serialVersionUID = 7440297955003302414L;@Id@Column(name="employee_id")private long employeeId;@Column(name="employee_name", nullable = false, length=30)private String employeeName;@Column(name="employee_surname", nullable = false, length=30)private String employeeSurname;@Column(name="job", length=50)private String job;public EmployeeDTO() {}public EmployeeDTO(int employeeId) {this.employeeId = employeeId;  }public EmployeeDTO(long employeeId, String employeeName, String employeeSurname,String job) {this.employeeId = employeeId;this.employeeName = employeeName;this.employeeSurname = employeeSurname;this.job = job;}public long getEmployeeId() {return employeeId;}public void setEmployeeId(long employeeId) {this.employeeId = employeeId;}public String getEmployeeName() {return employeeName;}public void setEmployeeName(String employeeName) {this.employeeName = employeeName;}public String getEmployeeSurname() {return employeeSurname;}public void setEmployeeSurname(String employeeSurname) {this.employeeSurname = employeeSurname;}public String getJob() {return job;}public void setJob(String job) {this.job = job;}
}

最后但并非最不重要的是,下面提供了“業務”服務接口和實現類:

import java.util.List;import com.javacodegeeks.springdatanucleus.dto.EmployeeDTO;public interface EmployeeService {public EmployeeDTO findEmployee(long employeeId);public List<EmployeeDTO> findAllEmployees();public void saveEmployee(long employeeId, String name, String surname, String jobDescription) throws Exception;public void updateEmployee(long employeeId, String name, String surname, String jobDescription) throws Exception;public void saveOrUpdateEmployee(long employeeId, String name, String surname, String jobDescription) throws Exception;public void deleteEmployee(long employeeId) throws Exception;}
import java.util.List;import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;import com.javacodegeeks.springdatanucleus.dao.EmployeeDAO;
import com.javacodegeeks.springdatanucleus.dto.EmployeeDTO;
import com.javacodegeeks.springdatanucleus.services.EmployeeService;@Service("employeeService")
public class EmployeeServiceImpl implements EmployeeService {@Autowiredprivate EmployeeDAO employeeDAO;@PostConstructpublic void init() throws Exception {}@PreDestroypublic void destroy() {}public EmployeeDTO findEmployee(long employeeId) {return employeeDAO.findById(employeeId);}public List<EmployeeDTO> findAllEmployees() {return employeeDAO.findAll();}@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)public void saveEmployee(long employeeId, String name, String surname, String jobDescription) throws Exception {EmployeeDTO employeeDTO = employeeDAO.findById(employeeId);if(employeeDTO == null) {employeeDTO = new EmployeeDTO(employeeId, name,surname, jobDescription);employeeDAO.persist(employeeDTO);}}@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)public void updateEmployee(long employeeId, String name, String surname, String jobDescription) throws Exception {EmployeeDTO employeeDTO = employeeDAO.findById(employeeId);if(employeeDTO != null) {employeeDTO.setEmployeeName(name);employeeDTO.setEmployeeSurname(surname);employeeDTO.setJob(jobDescription);}}@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)public void deleteEmployee(long employeeId) throws Exception {EmployeeDTO employeeDTO = employeeDAO.findById(employeeId);if(employeeDTO != null)employeeDAO.remove(employeeDTO);}@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)public void saveOrUpdateEmployee(long employeeId, String name, String surname, String jobDescription) throws Exception {EmployeeDTO employeeDTO = new EmployeeDTO(employeeId, name,surname, jobDescription);employeeDAO.merge(employeeDTO);}}

接下來是驅動Spring IoC容器的“ applicationContext.xml”文件。 在兩個“測試基礎”項目之間,該文件的內容也相同。

<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:task="http://www.springframework.org/schema/task"xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd"><context:component-scan base-package="com.javacodegeeks.springdatanucleus" /><tx:annotation-driven /><bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"><property name="persistenceUnitName" value="MyPersistenceUnit" /></bean><bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"><property name="entityManagerFactory" ref="entityManagerFactory" /></bean></beans>

為了能夠從Servlet容器啟動Spring應用程序(別忘了我們已經實現了基于Spring的WEB應用程序),我們在兩個“測試基礎”應用程序的“ web.xml”文件中都包含了以下偵聽器:

<listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

這兩個“測試基礎”項目之間唯一不同的文件是定義要使用的Java持久性API(JPA)的實際實現的文件-“ persistence.xml”文件。 以下是我們用來利用DataNucleus Access Platform的平臺:

<persistence xmlns="http://java.sun.com/xml/ns/persistence"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"version="2.0"><persistence-unit name="MyPersistenceUnit" transaction-type="RESOURCE_LOCAL"><provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider><class>com.javacodegeeks.springdatanucleus.dto.EmployeeDTO</class><exclude-unlisted-classes>true</exclude-unlisted-classes><properties><property name="datanucleus.storeManagerType" value="rdbms"/><property name="datanucleus.ConnectionDriverName"  value="org.apache.derby.jdbc.EmbeddedDriver"/><property name="datanucleus.ConnectionURL" value="jdbc:derby:runtime;create=true"/><!-- <property name="datanucleus.ConnectionUserName" value=""/><property name="datanucleus.ConnectionPassword" value=""/>--><property name="datanucleus.autoCreateSchema" value="true"/><property name="datanucleus.validateTables" value="false"/><property name="datanucleus.validateConstraints" value="false"/><property name="datanucleus.connectionPoolingType" value="C3P0"/><property name="datanucleus.connectionPool.minPoolSize" value="5" /><property name="datanucleus.connectionPool.initialPoolSize" value="5" /><property name="datanucleus.connectionPool.maxPoolSize" value="20" /><property name="datanucleus.connectionPool.maxStatements" value="50" /></properties></persistence-unit></persistence>

接下來是用于將Hibernate用作JPA2實現框架的“ persistence.xml”文件:

<persistence xmlns="http://java.sun.com/xml/ns/persistence"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"version="2.0"><persistence-unit name="MyPersistenceUnit" transaction-type="RESOURCE_LOCAL"><provider>org.hibernate.ejb.hibernatePersistence</provider><class>com.javacodegeeks.springhibernate.dto.EmployeeDTO</class><exclude-unlisted-classes>true</exclude-unlisted-classes><properties><property name="hibernate.hbm2ddl.auto" value="update" /><property name="hibernate.show_sql" value="false" /><property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect" /><property name="hibernate.connection.driver_class" value="org.apache.derby.jdbc.EmbeddedDriver" /><property name="hibernate.connection.url" value="jdbc:derby:runtime;create=true" /><!-- <property name="hibernate.connection.username" value="" /><property name="hibernate.connection.password" value="" />--><property name="hibernate.c3p0.min_size" value="5" /><property name="hibernate.c3p0.max_size" value="20" /><property name="hibernate.c3p0.timeout" value="300" /><property name="hibernate.c3p0.max_statements" value="50" /><property name="hibernate.c3p0.idle_test_period" value="3000" /></properties></persistence-unit></persistence>

最后,我們演示實現所有要執行的測試用例的類。 這兩個“測試基礎”項目的類是相同的:

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;import java.util.List;
import java.util.concurrent.Callable;import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;import bb.util.Benchmark;import com.javacodegeeks.springhibernate.dto.EmployeeDTO;
import com.javacodegeeks.springhibernate.services.EmployeeService;@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"file:src/main/webapp/WEB-INF/applicationContext.xml"})
public class EmployeeServiceTest {@AutowiredEmployeeService employeeService;@Testpublic void testSaveEmployee() {try {employeeService.saveEmployee(1, "byron", "kiourtzoglou", "master software engineer");employeeService.saveEmployee(2, "ilias", "tsagklis", "senior software engineer");} catch (Exception e) {fail(e.getMessage());}}@Testpublic void testFindEmployee() {assertNotNull(employeeService.findEmployee(1));}@Testpublic void testFindAllEmployees() {assertEquals(employeeService.findAllEmployees().size(), 2);}@Testpublic void testUpdateEmployee() {try {employeeService.updateEmployee(1, "panagiotis", "paterakis", "senior software engineer");assertEquals(employeeService.findEmployee(1).getEmployeeName(), "panagiotis");} catch (Exception e) {fail(e.getMessage());}}@Testpublic void testDeleteEmployee() {try {employeeService.deleteEmployee(1);assertNull(employeeService.findEmployee(1));} catch (Exception e) {fail(e.getMessage());}}@Testpublic void testSaveOrUpdateEmployee() {try {employeeService.saveOrUpdateEmployee(1, "byron", "kiourtzoglou", "master software engineer");assertEquals(employeeService.findEmployee(1).getEmployeeName(), "byron");} catch (Exception e) {fail(e.getMessage());}}@Testpublic void stressTestSaveEmployee() {Callable<Integer> task = new Callable<Integer>() { public Integer call() throws Exception {int i;for(i = 3;i < 2048; i++) {employeeService.saveEmployee(i, "name-" + i, "surname-" + i, "developer-" + i);}return i;}};try {System.out.println("saveEmployee(...): " + new Benchmark(task, false, 2045));} catch (Exception e) {fail(e.getMessage());}assertNotNull(employeeService.findEmployee(1024));}@Testpublic void stressTestFindEmployee() {Callable<Integer> task = new Callable<Integer>() { public Integer call() { int i;for(i = 1;i < 2048; i++) {employeeService.findEmployee(i);}return i;}};try {System.out.println("findEmployee(...): " + new Benchmark(task, 2047));} catch (Exception e) {fail(e.getMessage());}}@Testpublic void stressTestFindAllEmployees() {Callable<List<EmployeeDTO>> task = new Callable<List<EmployeeDTO>>() { public List<EmployeeDTO> call() {return employeeService.findAllEmployees();}};try {System.out.println("findAllEmployees(): " + new Benchmark(task));} catch (Exception e) {fail(e.getMessage());}}@Testpublic void stressTestUpdateEmployee() {Callable<Integer> task = new Callable<Integer>() { public Integer call() throws Exception { int i;for(i=1;i<2048;i++) {employeeService.updateEmployee(i, "new_name-" + i, "new_surname-" + i, "new_developer-" + i);}return i;}};try {System.out.println("updateEmployee(...): " + new Benchmark(task, false, 2047));} catch (Exception e) {fail(e.getMessage());}assertEquals("new_name-1", employeeService.findEmployee(1).getEmployeeName());}@Testpublic void stressTestDeleteEmployee() {Callable<Integer> task = new Callable<Integer>() { public Integer call() throws Exception {int i;for(i = 1;i < 2048; i++) {employeeService.deleteEmployee(i);}return i;}};try {System.out.println("deleteEmployee(...): " + new Benchmark(task, false, 2047));} catch (Exception e) {fail(e.getMessage());}assertEquals(true, employeeService.findAllEmployees().isEmpty());}}

結果 …

下圖顯示了所有測試結果。 縱軸表示每個測試的平均執行時間(以微秒(us)為單位),因此值越低越好。 橫軸表示測試類型。 從上面的測試案例中可以看到,我們在數據庫中插入了總數為2047個“員工”記錄。 對于檢索測試用例(findEmployee(…)和findAllEmployees(…)),基準測試框架對每個測試用例進行了60次重復,以計算統計數據。 所有其他測試用例僅執行一次。

如您所見,在每個測試用例中, Hibernate的性能都優于DataNucleus 。 特別是在通過ID(查找)方案進行檢索時, Hibernate比DataNucleus快9倍!

我認為DataNucleus是一個很好的平臺。 當您要處理所有形式的數據(無論存儲在何處)時,可以使用它。 從數據持久性到異構數據存儲,到提供使用多種查詢語言進行檢索的方法。

使用這種多功能平臺來管理應用程序數據的主要優點是,您無需花費大量時間來學習特定數據存儲或查詢語言的特殊性。 另外,您可以對所有數據使用單個通用接口,因此您的團隊可以將他們的應用程序開發時間集中在添加業務邏輯上,并讓DataNucleus處理數據管理問題。

另一方面,多功能性要付出代價。 作為關系映射(ORM)框架的“硬核”對象, Hibernate在我們所有的ORM測試中均輕松勝過DataNucleus 。

像大多數時候一樣,由應用程序架構師決定最適合其需求的功能(多功能性或性能),直到DataNucleus團隊將其產品開發到可以勝過Hibernate的地步為止;-)

祝您編碼愉快,不要忘記分享!

拜倫

相關文章:


翻譯自: https://www.javacodegeeks.com/2011/02/datanucleus-30-vs-hibernate-35.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:
http://www.pswp.cn/news/374646.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/374646.shtml
英文地址,請注明出處:http://en.pswp.cn/news/374646.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

手工內存管理規則的總結

1.如果需要保持一個對象不被銷毀,可以使用retain.在使用完對象后,需要使用release銷毀 2.給對象發送release消息并不會銷毀對象,只有當這個對象的引用計數減為0時,對象才會被銷毀.然后系統會發送dealloc消息給這個對象用于釋放它的內存. 對使用了retain或者copy,mutableCopy,al…

Java 字符,整型,字符串三者轉換

1.整型 —> 字符型 先把整型轉化為字符串&#xff0c;再把字符串轉化為字符 //整型 ---> 字符型 toString(int n).charAt(int index) System.out.println(Integer.toString(20).charAt(0));2.整型 —> 字符串 //整型 ---> 字符串 Inte…

AngularJS 的常用特性(二)

3、列表、表格以及其他迭代型元素 ng-repeat可能是最有用的 Angular 指令了&#xff0c;它可以根據集合中的項目一次創建一組元素的多份拷貝。 比如一個學生名冊系統需要從服務器上獲取學生信息&#xff0c;目前先把模型之間定義在 JavaScript 代碼里面&#xff1a; 1 var stud…

Ruby,Python和Java中的Web服務

今天&#xff0c;我不得不準備一些示例來說明Web服務是可互操作的。 因此&#xff0c;我已經使用Metro使用Java創建了一個簡單的Web服務&#xff0c;并在Tomcat上啟動了它。 然后嘗試使用Python和Ruby消耗它們。 這是全部完成的過程… Java中的Web服務 我從Java中的簡單Web服…

bzoj4199: [Noi2015]品酒大會

題面見http://uoj.ac/problem/131 一道后綴數組題 先求出height&#xff0c;然后從大到小枚舉每個height。 然后對于每個height值&#xff0c;兩端的集合中任意一對后綴的LCP都是這個height。 我們統計答案之后合并兩端的集合&#xff0c;用并查集維護即可。 1 #include<cst…

css中position初解

positon:static|absolute|relative|fiexd 1、static為默認值&#xff0c;沒有定位&#xff0c;元素出現在正常的文檔流中&#xff0c;忽略left,right,top,bottom,i-index值。 2、absolute為絕對定位&#xff0c;通過left,top等值對元素進行定位&#xff0c;定位時如果父元素的p…

零XML的Spring配置

Tomasz Nurkiewicz是我們的JCG合作伙伴之一&#xff0c;也是Spring框架的堅定支持者&#xff0c;在他的最新文章中描述了如何在不使用XML的情況下配置Spring應用程序。 注解方法在頂部。 查看他的教程&#xff1a; 沒有XML的Spring框架...根本&#xff01; 翻譯自: https://ww…

用動畫切換按鈕的狀態

用動畫切換按鈕的狀態 效果 源碼 https://github.com/YouXianMing/UI-Component-Collection // // BaseControl.h // BaseButton // // Created by YouXianMing on 15/8/27. // Copyright (c) 2015年 YouXianMing. All rights reserved. //#import <UIKit/UIKit.h> c…

iOS開發之學前了解

學iOS開發能做什么&#xff1f; iOS開發需要學習哪些內容&#xff1f; 先學習什么&#xff1f; 不管你是學習android開發還是iOS開發 都建議先學習UI&#xff0c;原因如下&#xff1a; UI是app的根基&#xff1a;一個app應該是先有UI界面&#xff0c;然后在UI的基礎上增加實用功…

力扣gupiao

給定一個數組 prices &#xff0c;它的第 i 個元素 prices[i] 表示一支給定股票第 i 天的價格。 你只能選擇 某一天 買入這只股票&#xff0c;并選擇在 未來的某一個不同的日子 賣出該股票。設計一個算法來計算你所能獲取的最大利潤。 返回你可以從這筆交易中獲取的最大利潤。…

Java相當好的隱私(PGP)

公鑰加密 這篇文章討論了PGP或“很好的隱私”。 PGP是常規加密和公用密鑰加密的混合實現。 在詳細介紹PGP之前&#xff0c;讓我們先談談公鑰加密。 與其他任何加密技術一樣&#xff0c;公鑰加密解決了通過不安全介質傳輸安全數據的問題。 即互聯網。 結果&#xff0c;該方案的…

HDU 5691 Sitting in Line 狀壓dp

Sitting in Line題目連接&#xff1a; http://acm.hdu.edu.cn/showproblem.php?pid5691 Description 度度熊是他同時代中最偉大的數學家&#xff0c;一切數字都要聽命于他。現在&#xff0c;又到了度度熊和他的數字仆人們玩排排坐游戲的時候了。游戲的規則十分簡單&#xff0c…

hello oc

printf("Hello C\n"); //OC可以采用C語言的輸出方式 printf("The number is %d\n",100);//%d 輸出數字 printf("Hello %s\n","XiaoMing");//%s 輸出字符 NSLog("Hello Objective-C"); //采用oc的輸出&#xff0c;前面帶了一…

Spring3 RESTful Web服務

Spring 3提供了對RESTful Web服務的支持。 在本教程中&#xff0c;我們將向您展示如何在Spring中實現RESTful Web服務 &#xff0c;或者如何將現有的Spring服務公開為RESTful Web服務 。 為了使事情變得更有趣&#xff0c;我們將從上一篇關于Spring GWT Hibernate JPA Infinisp…

zoj 3765 塊狀鏈表 OR splay

各種操作o(╯□╰)o...不過都挺簡單&#xff0c;不需要lazy標記。 方法1&#xff1a;塊狀鏈表 塊狀鏈表太強大了&#xff0c;區間操作實現起來簡單暴力&#xff0c;效率比splay稍微慢一點&#xff0c;內存開銷小很多。 1 #include <iostream>2 #include <cstring>3…

【C#公共幫助類】 Image幫助類

大家知道&#xff0c;開發項目除了數據訪問層很重要外&#xff0c;就是Common了&#xff0c;這里就提供了強大且實用的工具。 【C#公共幫助類】 Convert幫助類 Image類&#xff1a; using System; using System.Collections.Generic; using System.Text; using System.IO; usin…

Java泛型快速教程

泛型是Java SE 5.0引入的一種Java功能&#xff0c;在其發布幾年后&#xff0c;我發誓那里的每個Java程序員不僅聽說過它&#xff0c;而且已經使用過它。 關于Java泛型&#xff0c;有很多免費和商業資源&#xff0c;而我使用的最佳資源是&#xff1a; Java教程 Java泛型和集合…

876. 鏈表的中間結點

給定一個頭結點為 head 的非空單鏈表&#xff0c;返回鏈表的中間結點。 如果有兩個中間結點&#xff0c;則返回第二個中間結點 代碼一&#xff1a; 自己想的一個方法 class Solution {public ListNode middleNode(ListNode head) {ListNode p1 head;ListNode p2 head;//i,j…

Hive查詢Join

Select a.val,b.val From a [Left|Right|Full Outer] Join b On (a.keyb.key); 現有兩張表&#xff1a;sales 列出了人名及其所購商品的 ID&#xff1b;things 列出商品的 ID 和名稱&#xff1a; hive> select * from sales; OK Joe 2 Hank 4 Ali 0 Eve 3 Ha…

jquery 獲取easyui combobox選中的值

$(#comboboxlist).combobox(getValue);轉載于:https://www.cnblogs.com/ftm-datablogs/p/5526857.html