mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00: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
3 changed files with 12 additions and 14 deletions
2
.github/workflows/docker-build-test.yml
vendored
2
.github/workflows/docker-build-test.yml
vendored
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue