How do I use mysql's compress() and uncompress() functions to compress text before I store it and uncompress it when I retrieve it using a mysql database with hibernate for ORM?
Asked
Active
Viewed 3,233 times
3 Answers
6
See the ColumnTransformer, IIRC since 3.6:
@Column(name = "data", columnDefinition = "BLOB", nullable = false)
@ColumnTransformer(read = "UNCOMPRESS(data)", write = "COMPRESS(?)")
@Lob
public byte[] getData()
{
return theData;
}

Claudio
- 82
- 2
- 4
-
SELECT CHAR_LENGTH(UNCOMPRESS(COMPRESS(REPEAT('a1',9000)))); – zloctb Jun 16 '15 at 09:29
1
hmm native queries? But i dont have to tell you that your application will depend on a mysql rdbms then ;)

fasseg
- 17,504
- 8
- 62
- 73