Replace left joins with inner joins (#199)

* Replace left joins with inner joins.

* Temporarily disable YugabyteDB CI
This commit is contained in:
Kavin 2022-02-24 12:27:23 +00:00 committed by GitHub
parent 79b00f52e5
commit 78082742ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 14 deletions

View file

@ -15,7 +15,7 @@ jobs:
- docker-compose.yml
- testing/docker-compose.hsqldb.yml
- testing/docker-compose.cockroachdb.yml
- testing/docker-compose.yugabytedb.yml
#- testing/docker-compose.yugabytedb.yml
steps:
- uses: actions/checkout@v2.4.0
- name: Create Version File

View file

@ -1,18 +1,16 @@
package me.kavin.piped.utils;
import java.util.List;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Root;
import org.hibernate.Session;
import me.kavin.piped.utils.obj.db.Channel;
import me.kavin.piped.utils.obj.db.PubSub;
import me.kavin.piped.utils.obj.db.User;
import me.kavin.piped.utils.obj.db.Video;
import org.hibernate.Session;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Root;
import java.util.List;
public class DatabaseHelper {
@ -29,7 +27,7 @@ public class DatabaseHelper {
CriteriaBuilder cb = s.getCriteriaBuilder();
CriteriaQuery<User> cr = cb.createQuery(User.class);
Root<User> root = cr.from(User.class);
root.fetch("subscribed_ids", JoinType.LEFT);
root.fetch("subscribed_ids", JoinType.INNER);
cr.select(root).where(root.get("sessionId").in(session));
return s.createQuery(cr).uniqueResult();
@ -57,7 +55,7 @@ public class DatabaseHelper {
CriteriaBuilder cb = s.getCriteriaBuilder();
CriteriaQuery<Video> cr = cb.createQuery(Video.class);
Root<Video> root = cr.from(Video.class);
root.fetch("channel", JoinType.LEFT);
root.fetch("channel", JoinType.INNER);
cr.select(root).where(root.get("channel").get("uploader_id").in(id));
return s.createQuery(cr).getResultList();

View file

@ -736,7 +736,7 @@ public class ResponseHelper {
criteria.distinct(true);
var root = criteria.from(Video.class);
var userRoot = criteria.from(User.class);
root.fetch("channel", JoinType.LEFT);
root.fetch("channel", JoinType.INNER);
criteria.select(root)
.where(cb.and(
@ -792,7 +792,7 @@ public class ResponseHelper {
criteria.distinct(true);
var root = criteria.from(Video.class);
var userRoot = criteria.from(User.class);
root.fetch("channel", JoinType.LEFT);
root.fetch("channel", JoinType.INNER);
criteria.select(root)
.where(cb.and(