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?
如何使用mysql的compress()和uncompress()函数在存储文本之前进行压缩,并在使用hibernate为ORM的mysql数据库检索文本时进行解压?
3 个解决方案
#1
4
See the ColumnTransformer, IIRC since 3.6:
见ColumnTransformer, IIRC自3.6起:
@Column(name = "data", columnDefinition = "BLOB", nullable = false)
@ColumnTransformer(read = "UNCOMPRESS(data)", write = "COMPRESS(?)")
@Lob
public byte[] getData()
{
return theData;
}
#2
1
hmm native queries? But i dont have to tell you that your application will depend on a mysql rdbms then ;)
嗯原生查询?但我不必告诉您,您的应用程序将依赖于mysql rdbms;
#3
0
A workaround would be to use stored procedures instead of queries. Stored procedures supported by hibernate. That's likely to get unwieldy, though.
解决方法是使用存储过程而不是查询。hibernate支持的存储过程。不过,这可能会变得难以处理。
#1
4
See the ColumnTransformer, IIRC since 3.6:
见ColumnTransformer, IIRC自3.6起:
@Column(name = "data", columnDefinition = "BLOB", nullable = false)
@ColumnTransformer(read = "UNCOMPRESS(data)", write = "COMPRESS(?)")
@Lob
public byte[] getData()
{
return theData;
}
#2
1
hmm native queries? But i dont have to tell you that your application will depend on a mysql rdbms then ;)
嗯原生查询?但我不必告诉您,您的应用程序将依赖于mysql rdbms;
#3
0
A workaround would be to use stored procedures instead of queries. Stored procedures supported by hibernate. That's likely to get unwieldy, though.
解决方法是使用存储过程而不是查询。hibernate支持的存储过程。不过,这可能会变得难以处理。