Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,29 @@

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;

@Entity
public class Document {
public class DocumentEntity {

@Id
private Long id;
private String fileName;
private String title;
// Getters and setters

@Lob
private String content;

public DocumentEntity() {}

public DocumentEntity(Long id, String content) {
this.id = id;
this.content = content;
}

public Long getId() {
return id;
}

public String getContent() {
return content;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import io.openliberty.jpa.persistence.tests.models.AsciiCharacter;
import io.openliberty.jpa.persistence.tests.models.Book;
import io.openliberty.jpa.persistence.tests.models.DateTimeEntity;
import io.openliberty.jpa.persistence.tests.models.DocumentEntity;
import io.openliberty.jpa.persistence.tests.models.Employee;
import io.openliberty.jpa.persistence.tests.models.Event;
import io.openliberty.jpa.persistence.tests.models.Organization;
Expand Down Expand Up @@ -1879,6 +1880,38 @@ public void testCacheStoreMode_QueryOverridesEM_BypassOverridesRefresh() throws
assertFalse(inCache);
}

@Test
@SkipIfSysProp(DB_Oracle) // Reference issue: https://github.com/OpenLiberty/open-liberty/issues/33573
public void testLobInsertAndRetrieve() throws Exception {

try {
DocumentEntity e1 = new DocumentEntity(1L, "");

tx.begin();
em.persist(e1);
tx.commit();

} catch (Exception e) {
if (tx.getStatus() == jakarta.transaction.Status.STATUS_ACTIVE) {
tx.rollback();
}
throw e;
}

try {
tx.begin();

DocumentEntity r1 = em.find(DocumentEntity.class, 1L);

assertEquals("", r1.getContent());
tx.commit();
} catch (Exception e) {
if (tx.getStatus() == jakarta.transaction.Status.STATUS_ACTIVE) {
tx.rollback();
}
throw e;
}
}

/**
* Utility method to drop all entities from table.
Expand Down