Skip to content

Commit

Permalink
fix: 직렬화 저장 오류 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
SJ70 committed Oct 12, 2024
1 parent aad2534 commit ac968fa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.j9.bestmoments.converter;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import java.util.Arrays;
import java.util.List;

@Converter
public class StringListConverter implements AttributeConverter<List<String>, String> {

private static final String SEPARATOR = ",";

@Override
public String convertToDatabaseColumn(List<String> attribute) {
return String.join(SEPARATOR, attribute);
}

@Override
public List<String> convertToEntityAttribute(String dbData) {
return Arrays.asList(dbData.split(SEPARATOR));
}

}
3 changes: 3 additions & 0 deletions src/main/java/com/j9/bestmoments/domain/Video.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.j9.bestmoments.domain;

import com.j9.bestmoments.converter.StringListConverter;
import jakarta.persistence.Convert;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
Expand Down Expand Up @@ -35,6 +37,7 @@ public class Video {
private String videoUrl;
private String thumbnailUrl;
@Lob
@Convert(converter = StringListConverter.class)
private List<String> encodedVideoUrls;

private String title;
Expand Down

0 comments on commit ac968fa

Please sign in to comment.