• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

vladmihalcea/high-performance-java-persistence: The High-Performance Java Persis ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

vladmihalcea/high-performance-java-persistence

开源软件地址:

https://github.com/vladmihalcea/high-performance-java-persistence

开源编程语言:

Java 99.9%

开源软件介绍:

High-Performance Java Persistence

The High-Performance Java Persistence book and video course code examples. I wrote this article about this repository since it's one of the best way to test JDBC, JPA, Hibernate or even jOOQ code. Or, if you prefer videos, you can watch this presentation on YouTube.

Are you struggling with application performance issues?

Hypersistence Optimizer

Imagine having a tool that can automatically detect if you are using JPA and Hibernate properly. No more performance issues, no more having to spend countless hours trying to figure out why your application is barely crawling.

Imagine discovering early during the development cycle that you are using suboptimal mappings and entity relationships or that you are missing performance-related settings.

More, with Hypersistence Optimizer, you can detect all such issues during testing and make sure you don't deploy to production a change that will affect data access layer performance.

Hypersistence Optimizer is the tool you've been long waiting for!

Training

If you are interested in on-site training, I can offer you my High-Performance Java Persistence training which can be adapted to one, two or three days of sessions. For more details, check out my website.

Consulting

If you want me to review your application and provide insight into how you can optimize it to run faster, then check out my consulting page.

High-Performance Java Persistence Video Courses

If you want the fastest way to learn how to speed up a Java database application, then you should definitely enroll in my High-Performance Java Persistence video courses.

High-Performance Java Persistence Book

Or, if you prefer reading books, you are going to love my High-Performance Java Persistence book as well.

High-Performance Java Persistence book High-Performance Java Persistence video course

Java

All examples require at least Java 16 because of the awesome Text Blocks feature, which makes JPQL and SQL queries so much readable.

Maven

You need to use Maven 3.6.2 or newer and configure Maven Toolchains as follows:

  1. You need to create a toolchains.xml file in the Maven Home folder (e.g., %M2_HOME% on Windows, $M2_HOME on Unix based systems). For example, on Windows, the toolchains.xml file is going to be located at this path: c:\Users\%USERNAME%\.m2\toolchains.xml.

  2. Inside the toolchains.xml, you need to define the installation path of Java 13 or newer, as follows:

     <toolchains>
       <toolchain>
         <type>jdk</type>
         <provides>
           <id>Java16</id>
           <version>16</version>
         </provides>
         <configuration>
           <jdkHome>${env.JAVA_HOME_16}</jdkHome>
         </configuration>
       </toolchain>
     </toolchains>
    

In my example, the JAVA_HOME_16 is an environment variable pointing to a local folder where Java 16 is installed.

For more details about using Maven Toolchains, check out this article.

IntelliJ IDEA

On IntelliJ IDEA, the project runs just fine. You will have to make sure to select Java 13 or newer and enable the preview features as illustrated by the following diagram:

HHow to set up IntelliJ IDEA to enable the Java 13 preview features

Eclipse

If you're using Eclipse, you must use the Open JDK compiler and not the Eclipse-based one which suffers from this issue.

However, on Eclipse it has been reported that you need to consider the following configurations. Many thanks to Urs Joss for the hints:

  1. Eclipse does not automatically treat the generated sources by jpamodelgen as source folders. You need to add a dependency on hibernate-jpamodelgen and use the build-helper-maven-plugin to source the folders with the generated sources.
  2. Secondly, the Maven eclipse plugin e2m seems to have an issue with some plugin configurations. Make sure you configure e2m to ignore the false positives issues since the project runs just fine from a Maven command line.

Database setup

The Integration Tests require some external configurations:

  • PostgreSQL

    You should install PostgreSQL and the password for the postgres user should be admin.

    Now you need to create a high_performance_java_persistence database.

  • Oracle

    You need to download and install Oracle XE

    Set the sys password to admin

    Connect to Oracle using the "sys as sysdba" user and create a new user:

      alter session set "_ORACLE_SCRIPT"=true;
    
      create user oracle identified by admin default tablespace users;
    
      grant dba to oracle;
    
      alter system set processes=1000 scope=spfile;
    
      alter system set sessions=1000 scope=spfile;
      
      ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
    

    Open the C:\app\${user.name}\product\21c\homes\OraDB21Home1\network\admin folder where ${user.name} is your current Windows username.

    Locate the tnsnames.ora and listener.ora files and change the port from 1522 to 1521 if that's the case. If you made these modifications, you need to restart the OracleOraDB21Home1TNSListener and OracleServiceXE Windows services.

  • MySQL

    You should install MySQL 8 and the password for the mysql user should be admin.

    Now, you need to create a high_performance_java_persistence schema

    Beside having all privileges on this schema, the mysql user also requires select permission on mysql.PROC.

    If you don't have a mysql user created at database installation time, you can create one as follows:

    CREATE USER 'mysql'@'localhost';
    
    SET PASSWORD for 'mysql'@'localhost'='admin';
    
    GRANT ALL PRIVILEGES ON high_performance_java_persistence.* TO 'mysql'@'localhost';
    
    GRANT SELECT ON mysql.* TO 'mysql'@'localhost';
    
    FLUSH PRIVILEGES;
    
  • SQL Server

    You should install SQL Server Express Edition with Tools. Chose mixed mode authentication and set the sa user password to adm1n.

    Open SQL Server Configuration Manager -> SQL Server Network Configuration and enable Named Pipes and TCP

    In the right pane of the TCP/IP option, choose Properties, then IP Addresses and make sure you Enable all listed IP addresses. You need to blank the dynamic TCP port value and configure the static TCP port 1433 for all IPs.

    Open SQL Server Management Studio and create the high_performance_java_persistence database

Maven

To build the project, don't use install or package. Instead, just compile test classes like this:

mvn clean test-compile

Or you can just run the build.bat or build.sh scripts which run the above Maven command.

Afterward, just pick one test from the IDE and run it individually.

Don't you run all tests at once (e.g. mvn clean test) because the test suite will take a very long time to complete.

So, run the test you are interested in individually.

Enjoy learning more about Java Persistence, Hibernate, and database systems!




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap