Hibernate – JPA @LOB attribute encoding cannot be used with PostgreSQL text

JPA Mapping

I am using JPA and Hibernate. I have an entity with @Lob attributes

@Column(nullable=false)
@Lob
private String text;

I am using PostgreSQL 8.4 and entities are correctly mapped to columns

"text" text NOT NULL

My view page uses UTF-8 encoding, and my URL connection also uses the correct encoding:

In addition, I am The client_encoding on posgreSQL is Unicode (using query tool) or UTF-8 (using psql).

Problem

Although I can read/save data, but when I display it There will be some encoding issues, such as display.

Another message is that I have another String attribute on the same entity, which correctly displays the same content of the @Lob attribute.

I also exported the text attribute of psql to the test.txt file, the content is normal.

I tested the value of the attribute before persisting (debugging), and the value is correct.

div>

based on this try to add a comment after @Lob @Type(type = “org.hibernate.type.StringClobType”)

JPA Mapping

I am using JPA and Hibernate. I have an entity with @Lob attribute

< pre>@Column(nullable=false)
@Lob
private String text;

I am using PostgreSQL 8.4 and the entity It has been correctly mapped to the column

"text" text NOT NULL

My view page uses UTF-8 encoding, and my URL connection is also correct Encoding:

 

In addition, my client_encoding on posgreSQL is Unicode (using query tool) or UTF-8 (using psql).

Question

Although I can read Fetch/save data, but when I display it, there will be some encoding issues, such as display.

Another message is that I have another String attribute on the same entity, which correctly displays the @Lob attribute The same content.

I also exported the text attribute of psql to the test.txt file, and the content is normal.

I tested the value of the attribute before persisting (debugging), and The value is correct.

Based on this, try to add the annotation @Type(type=“org.hibernate.type.StringClobType”) after @Lob.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4453 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.