Skip to content

Commit

Permalink
fix: transient value error
Browse files Browse the repository at this point in the history
  • Loading branch information
GODrums committed Aug 20, 2024
1 parent 28c226c commit 45a6140
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Repository getHephaestusRepository() {
example.setName("hephaestus");
example.setNameWithOwner("ls1intum/hephaestus");
Optional<Repository> foundRepo = codeReviewRepository.findOne(Example.of(example));
logger.info("All repositories: " + codeReviewRepository.findAll().toString());
logger.info("Repository count: " + codeReviewRepository.count());

logger.info("Saved repo: " + foundRepo.toString());
if (foundRepo.isPresent()) {
Expand All @@ -75,7 +75,8 @@ public Repository getHephaestusRepository() {
repository.setAddedAt(Instant.now());

System.out.println("Repository: " + repository.toString());
codeReviewRepository.save(repository);
codeReviewRepository.saveAndFlush(repository);
System.out.println("New Repository count: " + codeReviewRepository.count());
return repository;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import de.tum.in.www1.hephaestus.codereview.pullrequest.Pullrequest;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.OneToMany;
Expand Down Expand Up @@ -45,12 +44,12 @@ public class Actor {
/**
* The Pullrequests of the User entity.
*/
@OneToMany(mappedBy = "author", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "author")
private List<Pullrequest> pullrequests;

/**
* The Comments of the User entity.
*/
@OneToMany(mappedBy = "author", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "author")
private List<Comment> comments;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import jakarta.persistence.GenerationType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import lombok.Getter;
import lombok.Setter;

Expand Down Expand Up @@ -57,9 +58,9 @@ public class Comment {
private Actor author;

/**
* The pullrequest of the Comment entity.
* The parent connection to the pullrequest of the Comment entity.
*/
@ManyToOne(fetch = FetchType.LAZY)
@OneToOne(optional = false)
@JoinColumn(name = "c_connection_id", referencedColumnName = "id")
private CommentConnection connection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

import java.util.List;

import de.tum.in.www1.hephaestus.codereview.pullrequest.Pullrequest;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;
Expand All @@ -23,6 +20,6 @@ public class CommentConnection {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToMany(mappedBy = "connection", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "connection")
private List<Comment> nodes;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package de.tum.in.www1.hephaestus.codereview.pullrequest;

import java.time.Instant;

import de.tum.in.www1.hephaestus.codereview.actor.Actor;
import de.tum.in.www1.hephaestus.codereview.comment.CommentConnection;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
Expand Down Expand Up @@ -85,11 +83,14 @@ public class Pullrequest {
/**
* The comments of the Pullrequest entity.
*/
@OneToOne(optional = false)
@OneToOne(cascade = CascadeType.ALL, optional = false)
@JoinColumn(name = "c_connection_id", referencedColumnName = "id")
private CommentConnection comments;

@ManyToOne(fetch = FetchType.LAZY)
/**
* The parent connection of the Pullrequest entity.
*/
@OneToOne(optional = false)
@JoinColumn(name = "pr_connection_id", referencedColumnName = "id")
private PullrequestConnection connection;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

import java.util.List;

import de.tum.in.www1.hephaestus.codereview.repository.Repository;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import lombok.Getter;
Expand All @@ -23,6 +20,6 @@ public class PullrequestConnection {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToMany(mappedBy = "connection", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "connection")
private List<Pullrequest> nodes;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.time.Instant;

import de.tum.in.www1.hephaestus.codereview.pullrequest.PullrequestConnection;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
Expand Down Expand Up @@ -42,7 +43,7 @@ public class Repository {
@Column
private String url;

@OneToOne(optional = false)
@OneToOne(cascade = CascadeType.ALL, optional = false)
@JoinColumn(name = "connection_id", referencedColumnName = "id")
private PullrequestConnection pullRequests;

Expand Down

0 comments on commit 45a6140

Please sign in to comment.