mirror of
https://github.com/TeamPiped/Piped-Backend
synced 2025-09-05 21:11:05 +02:00
Replace left joins with inner joins (#199)
* Replace left joins with inner joins. * Temporarily disable YugabyteDB CI
This commit is contained in:
parent
79b00f52e5
commit
78082742ad
2
.github/workflows/docker-build-test.yml
vendored
2
.github/workflows/docker-build-test.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
|||||||
- docker-compose.yml
|
- docker-compose.yml
|
||||||
- testing/docker-compose.hsqldb.yml
|
- testing/docker-compose.hsqldb.yml
|
||||||
- testing/docker-compose.cockroachdb.yml
|
- testing/docker-compose.cockroachdb.yml
|
||||||
- testing/docker-compose.yugabytedb.yml
|
#- testing/docker-compose.yugabytedb.yml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.4.0
|
- uses: actions/checkout@v2.4.0
|
||||||
- name: Create Version File
|
- name: Create Version File
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
package me.kavin.piped.utils;
|
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.Channel;
|
||||||
import me.kavin.piped.utils.obj.db.PubSub;
|
import me.kavin.piped.utils.obj.db.PubSub;
|
||||||
import me.kavin.piped.utils.obj.db.User;
|
import me.kavin.piped.utils.obj.db.User;
|
||||||
import me.kavin.piped.utils.obj.db.Video;
|
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 {
|
public class DatabaseHelper {
|
||||||
|
|
||||||
@ -29,7 +27,7 @@ public class DatabaseHelper {
|
|||||||
CriteriaBuilder cb = s.getCriteriaBuilder();
|
CriteriaBuilder cb = s.getCriteriaBuilder();
|
||||||
CriteriaQuery<User> cr = cb.createQuery(User.class);
|
CriteriaQuery<User> cr = cb.createQuery(User.class);
|
||||||
Root<User> root = cr.from(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));
|
cr.select(root).where(root.get("sessionId").in(session));
|
||||||
|
|
||||||
return s.createQuery(cr).uniqueResult();
|
return s.createQuery(cr).uniqueResult();
|
||||||
@ -57,7 +55,7 @@ public class DatabaseHelper {
|
|||||||
CriteriaBuilder cb = s.getCriteriaBuilder();
|
CriteriaBuilder cb = s.getCriteriaBuilder();
|
||||||
CriteriaQuery<Video> cr = cb.createQuery(Video.class);
|
CriteriaQuery<Video> cr = cb.createQuery(Video.class);
|
||||||
Root<Video> root = cr.from(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));
|
cr.select(root).where(root.get("channel").get("uploader_id").in(id));
|
||||||
|
|
||||||
return s.createQuery(cr).getResultList();
|
return s.createQuery(cr).getResultList();
|
||||||
|
@ -736,7 +736,7 @@ public class ResponseHelper {
|
|||||||
criteria.distinct(true);
|
criteria.distinct(true);
|
||||||
var root = criteria.from(Video.class);
|
var root = criteria.from(Video.class);
|
||||||
var userRoot = criteria.from(User.class);
|
var userRoot = criteria.from(User.class);
|
||||||
root.fetch("channel", JoinType.LEFT);
|
root.fetch("channel", JoinType.INNER);
|
||||||
|
|
||||||
criteria.select(root)
|
criteria.select(root)
|
||||||
.where(cb.and(
|
.where(cb.and(
|
||||||
@ -792,7 +792,7 @@ public class ResponseHelper {
|
|||||||
criteria.distinct(true);
|
criteria.distinct(true);
|
||||||
var root = criteria.from(Video.class);
|
var root = criteria.from(Video.class);
|
||||||
var userRoot = criteria.from(User.class);
|
var userRoot = criteria.from(User.class);
|
||||||
root.fetch("channel", JoinType.LEFT);
|
root.fetch("channel", JoinType.INNER);
|
||||||
|
|
||||||
criteria.select(root)
|
criteria.select(root)
|
||||||
.where(cb.and(
|
.where(cb.and(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user