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

refactor: upgrade to hibernate 6 #1974

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
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
63 changes: 24 additions & 39 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<model.version>2.0.74</model.version>
<hibernate.version>5.6.15.Final</hibernate.version>
<jetty.version>10.0.22</jetty.version>
<spring.version>5.3.18</spring.version>
<hibernate.version>6.1.7.Final</hibernate.version>
<jetty.version>11.0.24</jetty.version>
<spring.version>6.0.8</spring.version>
<surefire-plugin.version>3.1.2</surefire-plugin.version>
</properties>

Expand Down Expand Up @@ -352,11 +352,6 @@
</dependency>

<!-- Apache Commons -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
Expand Down Expand Up @@ -462,49 +457,39 @@
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
<version>3.0.1</version>
</dependency>

<!-- Hibernate (ORM) -->
<dependency>
<groupId>org.hibernate</groupId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-ant</artifactId>
<version>${hibernate.version}</version>
</dependency>

<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.1.7.Final</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
<version>7.0.0.Final</version>
</dependency>

<!-- Database -->
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
Expand All @@ -524,15 +509,15 @@

<!-- Provided by Jetty -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.3</version>
<groupId>jakarta.servlet.jsp</groupId>
<artifactId>jakarta.servlet.jsp-api</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>

Expand Down
16 changes: 8 additions & 8 deletions src/main/config/DEPLOY.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Version: `17`

We use [Eclipse Jetty](https://jetty.org/) as our web server.

Version: `Jetty 10.0.22` (requires Java 11 or newer)
Version: `Jetty 11.0.24` (requires Java 11 or newer)

### Jetty Maven Plugin 🪶

Expand All @@ -45,23 +45,23 @@ You can find the download links for each release at https://jetty.org/download.h
On your production server, go to the temporary folder, and download the release:

cd /tmp
wget https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/10.0.22/jetty-home-10.0.22.tar.gz
wget https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/11.0.24/jetty-home-11.0.24.tar.gz

Extract the archive:

tar -zxvf jetty-home-10.0.22.tar.gz
tar -zxvf jetty-home-11.0.24.tar.gz

Move the folder to `/opt`:

mv jetty-home-10.0.22 /opt/
mv jetty-home-11.0.24 /opt/

### Configure Jetty ⚙️

#### System Startup

Add the `jetty` service:

ln -s /opt/jetty-home-10.0.22/bin/jetty.sh /etc/rc.d/init.d/jetty
ln -s /opt/jetty-home-11.0.24/bin/jetty.sh /etc/rc.d/init.d/jetty

Enable the `jetty` server on system init:

Expand All @@ -80,7 +80,7 @@ Create the folder that will contain Jetty configuration and `*.war` files:
Add Jetty modules:

cd /opt/jetty-base/
java -jar /opt/jetty-home-10.0.22/start.jar --add-module=server,http,deploy,jsp
java -jar /opt/jetty-home-11.0.24/start.jar --add-module=server,http,deploy,jsp

#### Set Default Values

Expand All @@ -102,7 +102,7 @@ Copy the port number configuration from [`centos-stream-9/opt/jetty-base/start.d

Add the latest release of your `*.war` file to `/opt/jetty-base/webapps/`. In our case, we download WAR releases from an external URL:

wget -O /opt/jetty-base/webapps/webapp.war https://jitpack.io/com/github/elimu-ai/webapp/webapp-2.4.25/webapp-webapp-2.4.25.war
wget -O /opt/jetty-base/webapps/webapp.war https://jitpack.io/com/github/elimu-ai/webapp/webapp-2.4.66/webapp-webapp-2.4.66.war

> [!IMPORTANT]
> The WAR file's name must match the context file's name, e.g. `webapp.war` and `webapp.xml`.
Expand All @@ -123,7 +123,7 @@ Start the `jetty` service:
systemctl start jetty

> [!TIP]
> To verify that everything has been configured correctly, you can run `cd /opt/jetty-base/; java -jar /opt/jetty-home-10.0.22/start.jar --list-config` and `systemctl status jetty`
> To verify that everything has been configured correctly, you can run `cd /opt/jetty-base/; java -jar /opt/jetty-home-11.0.24/start.jar --list-config` and `systemctl status jetty`

## MariaDB Database 🛢️

Expand Down
2 changes: 1 addition & 1 deletion src/main/config/centos-stream-9/etc/default/jetty
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
JETTY_HOME=/opt/jetty-home-10.0.22
JETTY_HOME=/opt/jetty-home-11.0.24
JETTY_BASE=/opt/jetty-base
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/dao/jpa/ApplicationDaoJpa.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ai.elimu.dao.jpa;

import java.util.List;
import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import ai.elimu.dao.ApplicationDao;
import ai.elimu.model.admin.Application;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ai.elimu.dao.jpa;

import java.util.List;
import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import ai.elimu.dao.ApplicationVersionDao;
import ai.elimu.model.admin.Application;
import ai.elimu.model.admin.ApplicationVersion;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/dao/jpa/AudioDaoJpa.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.List;

import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import ai.elimu.dao.AudioDao;
import ai.elimu.model.content.StoryBookParagraph;
import ai.elimu.model.content.Word;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import ai.elimu.model.contributor.AudioPeerReviewEvent;
import ai.elimu.model.contributor.Contributor;
import java.util.List;
import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import org.springframework.dao.DataAccessException;

public class AudioPeerReviewEventDaoJpa extends GenericDaoJpa<AudioPeerReviewEvent> implements AudioPeerReviewEventDao {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/dao/jpa/ContributorDaoJpa.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.Calendar;
import java.util.List;
import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import ai.elimu.dao.ContributorDao;

import org.springframework.dao.DataAccessException;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/dao/jpa/DbMigrationDaoJpa.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ai.elimu.dao.jpa;

import java.util.List;
import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import ai.elimu.dao.DbMigrationDao;

import org.springframework.dao.DataAccessException;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/dao/jpa/DeviceDaoJpa.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ai.elimu.dao.jpa;

import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import ai.elimu.dao.DeviceDao;

import org.springframework.dao.DataAccessException;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/dao/jpa/EmojiDaoJpa.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ai.elimu.dao.jpa;

import java.util.List;
import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import ai.elimu.dao.EmojiDao;

import org.springframework.dao.DataAccessException;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ai/elimu/dao/jpa/GenericDaoJpa.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import java.lang.reflect.Type;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/dao/jpa/ImageDaoJpa.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.List;

import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;

import org.springframework.dao.DataAccessException;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/dao/jpa/LetterDaoJpa.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ai.elimu.dao.jpa;

import java.util.List;
import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import ai.elimu.dao.LetterDao;

import org.springframework.dao.DataAccessException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import ai.elimu.model.analytics.LetterLearningEvent;
import ai.elimu.model.content.Letter;
import java.util.Calendar;
import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import org.springframework.dao.DataAccessException;

public class LetterLearningEventDaoJpa extends GenericDaoJpa<LetterLearningEvent> implements LetterLearningEventDao {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/dao/jpa/NumberDaoJpa.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ai.elimu.dao.jpa;

import java.util.List;
import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;

import org.springframework.dao.DataAccessException;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/dao/jpa/SoundDaoJpa.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ai.elimu.dao.jpa;

import java.util.List;
import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import ai.elimu.model.content.Sound;

import org.springframework.dao.DataAccessException;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/dao/jpa/StoryBookDaoJpa.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ai.elimu.dao.jpa;

import java.util.List;
import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import ai.elimu.dao.StoryBookDao;

import org.springframework.dao.DataAccessException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import ai.elimu.model.content.StoryBook;
import java.util.Calendar;
import java.util.List;
import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import org.springframework.dao.DataAccessException;

public class StoryBookLearningEventDaoJpa extends GenericDaoJpa<StoryBookLearningEvent> implements StoryBookLearningEventDao {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/dao/jpa/SyllableDaoJpa.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ai.elimu.dao.jpa;

import java.util.List;
import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import ai.elimu.dao.SyllableDao;

import org.springframework.dao.DataAccessException;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/dao/jpa/VideoDaoJpa.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.List;

import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import ai.elimu.dao.VideoDao;

import org.springframework.dao.DataAccessException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.Calendar;
import java.util.List;

import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import org.springframework.dao.DataAccessException;

public class VideoLearningEventDaoJpa extends GenericDaoJpa<VideoLearningEvent> implements VideoLearningEventDao {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ai/elimu/dao/jpa/WordDaoJpa.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package ai.elimu.dao.jpa;

import java.util.List;
import javax.persistence.NoResultException;
import javax.persistence.Query;
import jakarta.persistence.NoResultException;
import jakarta.persistence.Query;

import ai.elimu.model.v2.enums.content.WordType;
import org.springframework.dao.DataAccessException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import ai.elimu.model.analytics.WordLearningEvent;
import ai.elimu.model.content.Word;
import java.util.Calendar;
import javax.persistence.NoResultException;
import jakarta.persistence.NoResultException;
import org.springframework.dao.DataAccessException;

public class WordLearningEventDaoJpa extends GenericDaoJpa<WordLearningEvent> implements WordLearningEventDao {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/ai/elimu/model/BaseEntity.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package ai.elimu.model;

import java.io.Serializable;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;

@MappedSuperclass
public abstract class BaseEntity implements Serializable {
Expand Down
Loading