summaryrefslogtreecommitdiff
path: root/src/main/java/eu
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu')
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/bookmarks/Bookmark.java2
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java9
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatMessage.java1
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatResource.java6
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java4
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/posts/PostText.java6
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/posts/PostTextPK.java6
7 files changed, 21 insertions, 13 deletions
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/Bookmark.java b/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/Bookmark.java
index 01e8a99..25fe683 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/Bookmark.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/Bookmark.java
@@ -60,6 +60,7 @@ public class Bookmark extends Post<BookmarkText> {
if (text == null) {
text = new BookmarkText();
text.post = this;
+ text.postId = id;
text.language = "";
texts.put(text.language, text);
}
@@ -72,6 +73,7 @@ public class Bookmark extends Post<BookmarkText> {
if (text == null) {
text = new BookmarkText();
text.post = this;
+ text.postId = id;
text.language = "";
texts.put(text.language, text);
}
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java b/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java
index c9304b5..4d08298 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java
@@ -68,14 +68,15 @@ public class BookmarkResource extends PostResource {
var bookmark = new Bookmark();
bookmark.uri = uri.toString();
bookmark.tags = Set.of();
- bookmark.setTitle(title);
- bookmark.setDescription(description);
bookmark.owner = user;
bookmark.date = OffsetDateTime.now();
- assignPostTargets(visibility, user, bookmark);
+ bookmark.persist();
- bookmark.persistAndFlush();
+ bookmark.setTitle(title);
+ bookmark.setDescription(description);
+
+ assignPostTargets(visibility, user, bookmark);
return Response.seeOther(new URI("/bookmarks")).build();
}
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatMessage.java b/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatMessage.java
index 9181adf..40788d5 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatMessage.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatMessage.java
@@ -50,6 +50,7 @@ public class LazychatMessage extends Post<LazychatMessageText> {
if (text == null) {
text = new LazychatMessageText();
text.post = this;
+ text.postId = id;
text.language = "";
texts.put(text.language, text);
}
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatResource.java b/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatResource.java
index 4a36cf8..e93f7de 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatResource.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatResource.java
@@ -45,13 +45,13 @@ public class LazychatResource extends PostResource {
var user = Objects.requireNonNull(getCurrentUser());
var message = new LazychatMessage();
- message.setContent(text);
message.owner = user;
message.date = OffsetDateTime.now();
- assignPostTargets(visibility, user, message);
+ message.persist();
+ message.setContent(text);
- message.persistAndFlush();
+ assignPostTargets(visibility, user, message);
return Response.seeOther(new URI("/lazychat")).build();
}
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java b/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java
index db613ae..0be31d7 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java
@@ -325,9 +325,11 @@ public abstract class PostResource {
comment.date = OffsetDateTime.now();
comment.scope = Scope.comment;
comment.referees = List.of(post);
+
+ comment.persist();
+
comment.setContent(message);
assignPostTargets(post.getVisibility(), post.owner, comment);
- comment.persist();
var currentUser = getCurrentUser();
if (currentUser != null) {
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/posts/PostText.java b/src/main/java/eu/mulk/mulkcms2/benki/posts/PostText.java
index 5bc94c8..5e8dd29 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/posts/PostText.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/posts/PostText.java
@@ -18,6 +18,7 @@ import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
+import jakarta.persistence.MapsId;
import jakarta.persistence.Table;
import javax.annotation.CheckForNull;
import org.hibernate.annotations.Generated;
@@ -32,8 +33,8 @@ public abstract class PostText<OwningPost extends Post<?>> extends PanacheEntity
private static final int DESCRIPTION_CACHE_VERSION = 1;
@Id
- @Column(name = "post", nullable = false, insertable = false, updatable = false)
- public int postId;
+ @Column(name = "post", nullable = false)
+ public Integer postId;
@Id
@Column(name = "language", nullable = false, length = -1)
@@ -54,6 +55,7 @@ public abstract class PostText<OwningPost extends Post<?>> extends PanacheEntity
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Post.class)
@JoinColumn(name = "post", referencedColumnName = "id", nullable = false)
+ @MapsId("postId")
@JsonbTransient
public OwningPost post;
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/posts/PostTextPK.java b/src/main/java/eu/mulk/mulkcms2/benki/posts/PostTextPK.java
index 74ad89e..6526526 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/posts/PostTextPK.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/posts/PostTextPK.java
@@ -9,17 +9,17 @@ public class PostTextPK implements Serializable {
@Id
@Column(name = "post", nullable = false)
- private int postId;
+ private Integer postId;
@Id
@Column(name = "language", nullable = false, length = -1)
private String language;
- public int getPostId() {
+ public Integer getPostId() {
return postId;
}
- public void setPostId(int postId) {
+ public void setPostId(Integer postId) {
this.postId = postId;
}