Skip to content

Commit

Permalink
Development: Fix serialization error for learner profiles with JsonIg…
Browse files Browse the repository at this point in the history
…noreProperties
  • Loading branch information
krusche committed Jan 22, 2025
1 parent fad4249 commit 8c26290
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.fasterxml.jackson.annotation.JsonInclude;

import de.tum.cit.aet.artemis.core.domain.Course;
import de.tum.cit.aet.artemis.core.domain.DomainObject;

@Entity
@Table(name = "course_learner_profile")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class CourseLearnerProfile extends DomainObject {

@ManyToOne
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,28 @@
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import de.tum.cit.aet.artemis.core.domain.DomainObject;
import de.tum.cit.aet.artemis.core.domain.User;

@Entity
@Table(name = "learner_profile")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class LearnerProfile extends DomainObject {

@JsonIgnoreProperties("learnerProfile")
@OneToOne(mappedBy = "learnerProfile", cascade = CascadeType.PERSIST)
private User user;

@OneToMany(mappedBy = "learnerProfile", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JsonIgnoreProperties("learnerProfile")
private Set<CourseLearnerProfile> courseLearnerProfiles = new HashSet<>();

public void setUser(User user) {
Expand Down

0 comments on commit 8c26290

Please sign in to comment.