Hello,

I am trying to set up an entityclass with a postgres server. I need this database to store some images i upload with the primefaces < p:fileUpload/> tag. With this tag the images are uploaded as a UploadedFile, now I can access the contents via getContents() and I will get the image as a Bytearray (byte[] in Java) .

Now I need to know how can i save this Byte Array via the entityclasses in my postgres database. Postgres allows the datatype bytea for a column for this datatype, but if I add Bytearray as a type for the column in the entityclass AxonIvy throws this error: The field type 'Binary' does not support persistence.

So my question is:
Is there any possibility i can save bytearray or blobs on my postgres server via the entity class?
What are all the classes which support persistence?

Thanks

asked 11.10 at 11:00

markusinho's gravatar image

markusinho
111
accept rate: 0%


Hi

This is not possible with the Entity Class Editor. But you can write your own Java Class:

package partner.protal.database;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;

@Entity
public class NewsImages {

 @Id
 @GeneratedValue
 private Integer id;

 @Lob
 private byte[] imageValue;

 @Lob
 private String imageNews;

 public Integer getId() {
  return id;
 }

 public byte[] getImageValue() {
  return imageValue;
 }

 public void setImageValue(byte[] imageValue) {
  this.imageValue = imageValue;
 }

 public String getLongString() {
  return imageNews;
 }

 public void setLongString(String longString) {
  this.imageNews = longString;
 }
}

Java Entity Class in Designer

link

answered 24.10 at 02:45

Christian%20Strebel's gravatar image

Christian St... ♦
2.9k21231
accept rate: 90%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×29
×6
×4

Asked: 11.10 at 11:00

Seen: 87 times

Last updated: 24.10 at 02:45