我有一个Base64编码的图像.在Java中解码它的最佳方法是什么?希望仅使用Sun Java 6附带的库.
我有一个使用hibernate 3.1和JPA注释的应用程序.它有一些具有byte []属性的对象(1k - 200k大小).它使用JPA @Lob注释,而hibernate 3.1可以在所有主要数据库上读取这些内容 - 它似乎隐藏了JDBC Blob供应商的特性(应该这样做).
@Entity
public class ConfigAttribute {
  @Lob
  public byte[] getValueBuffer() {
    return m_valueBuffer;
  }
}
我们不得不升级到3.5,当我们发现hibernate 3.5 在postgresql中打破(并且不会修复)这个注释组合时(没有解决方法).到目前为止我还没有找到明确的解决方法,但我注意到如果我只是删除了@Lob,它使用了postgresql类型的bytea(有效,但只适用于postgres).
annotation                   postgres     oracle      works on
-------------------------------------------------------------
byte[] + @Lob                oid          blob        oracle
byte[]                       bytea        raw(255)    postgresql
byte[] + @Type(PBA)          oid          blob        oracle
byte[] + @Type(BT)           bytea        blob        postgresql
once you use @Type, @Lob seems to not be relevant
note: oracle seems to have deprecated the "raw" type since 8i.
我正在寻找一种方法来拥有一个可以在主要数据库之间移植的带注释的类(具有blob属性).