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.mzph.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