Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code sample - 23c SpringBoot JPA Hibernate UCP #315

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 178 additions & 0 deletions java/23ai-springboot3-jpa-ucp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# Java related
target/
*.jar
*.war
*.ear
*.class

# Log file
*.log

# Package Files
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# JVM crash logs - http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Eclipse.gitignore - https://github.com/github/gitignore/blob/main/Global/Eclipse.gitignore
.metadata
.classpath
.project
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# CDT- autotools
.autotools

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/

# Annotation Processing
.apt_generated/
.apt_generated_test/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet

# Uncomment this line if you wish to ignore the project description file.
# Typically, this file would be tracked if it contains build/dependency configurations:
#.project

# External tool builders
.externalToolBuilders/

# VS Code - https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

# JetBrains .gitignore - https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
2 changes: 2 additions & 0 deletions java/23ai-springboot3-jpa-ucp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 23c-springboot3-jpa-ucp
[Java Persistence with Spring Boot 3, Spring Data JPA with Hibernate, and the Oracle Database 23c Free - Developer Release](https://rb.gy/i54khj)
90 changes: 90 additions & 0 deletions java/23ai-springboot3-jpa-ucp/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.0</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<groupId>com.oracle.dev.jdbc</groupId>
<artifactId>23ai-springboot3-jpa-ucp</artifactId>
<version>1.0-SNAPSHOT</version>
<name>23ai-springboot3-jpa-ucp</name>
<description>Java Persistence with Spring Boot 3, Spring Data JPA with
Hibernate, and the Oracle Database 23ai Free</description>
<url>
https://juarezjunior.medium.com/java-persistence-with-spring-boot-3-spring-data-jpa-with-hibernate-and-the-oracle-database-23c-9c0946d4838f</url>
<properties>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11-production</artifactId>
<version>23.6.0.24.10</version>
<type>pom</type>
</dependency>
<!-- Metrics -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.hibernate.orm.tooling</groupId>
<artifactId>hibernate-enhance-maven-plugin</artifactId>
<version>${hibernate.version}</version>
<executions>
<execution>
<id>enhance</id>
<goals>
<goal>enhance</goal>
</goals>
<configuration>
<enableLazyInitialization>true</enableLazyInitialization>
<enableDirtyTracking>true</enableDirtyTracking>
<enableAssociationManagement>true</enableAssociationManagement>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CREATE USER ORACLE_23C_USER IDENTIFIED BY <YOUR_PASSWORD>;
GRANT DB_DEVELOPER_ROLE TO ORACLE_23C_USER;
GRANT CREATE SESSION TO ORACLE_23C_USER;
GRANT UNLIMITED TABLESPACE TO ORACLE_23C_USER;

CREATE TABLE Employee
(id NUMBER(10) CONSTRAINT pk_employee PRIMARY KEY,
name VARCHAR2(20),
job VARCHAR2(20),
salary NUMBER(10),
commission NUMBER(10));

INSERT INTO Employee VALUES(7369,'JOHN','CLERK',7902,NULL);
INSERT INTO Employee VALUES(7499,'PETER','SALESMAN',7698,300);
INSERT INTO Employee VALUES(7521,'JEFF','SALESMAN',7698,500);
INSERT INTO Employee VALUES(7566,'MARK','MANAGER',7839,NULL);
INSERT INTO Employee VALUES(7654,'MARTIN','SALESMAN',7698,1400);
INSERT INTO Employee VALUES(7698,'ADAM','MANAGER',7839,NULL);
INSERT INTO Employee VALUES(7782,'CLARK','MANAGER',7839,NULL);
INSERT INTO Employee VALUES(7788,'SCOTT','ANALYST',7566,NULL);
INSERT INTO Employee VALUES(7839,'KING','PRESIDENT',NULL);
INSERT INTO Employee VALUES(7844,'TURNER','SALESMAN',0);
INSERT INTO Employee VALUES(7876,'ADAMS','CLERK',7788,NULL);
INSERT INTO Employee VALUES(7900,'JAMES','CLERK',7698,NULL);
INSERT INTO Employee VALUES(7902,'FORD','ANALYST',7566,NULL);
INSERT INTO Employee VALUES(7934,'MILLER','CLERK',7782,NULL);

COMMIT;

SELECT * FROM EMPLOYEE;
Loading