2012-05-29 6 views
5

これは、エンティティはBLOB型が含まれています:blobをebean&play 2で使用するには?

@Entity 
@Table(name="image_info") 
public class ImageInfo extends Model { 

    ....... 

    @Constraints.Required 
    private Blob image; 

    ....... 
} 

$ = trueを実行

を-DapplyEvolutions.default果たし、私は以下のようなエラーを得た:

[warn] c.j.b.ConnectionPartition - BoneCP detected an unclosed connection and will now attempt to close it for you. You should be closing this connection in your application - enable connectionWatch for additional debugging assistance. 
[error] c.a.e.s.t.r.ImmutableMetaFactory - Was unable to use reflection to find a constructor and appropriate getters forimmutable type interface java.sql.Blob. The errors while looking for the getter methods follow: 
[error] c.a.e.s.d.p.DeployCreateProperties - Error with models.ImageInfo field:image 
java.lang.RuntimeException: Unable to use reflection to build ImmutableMeta for interface  java.sql.Blob. Associated Errors trying to find a constructor and getter methods have been logged 
at com.avaje.ebeaninternal.server.type.reflect.ImmutableMetaFactory.createImmutableMeta(ImmutableMetaFactory.java:71) ~[ebean.jar:na] 
at com.avaje.ebeaninternal.server.type.DefaultTypeManager.recursiveCreateScalarTypes(DefaultTypeManager.java:227) ~[ebean.jar:na] 
at com.avaje.ebeaninternal.server.deploy.parse.DeployCreateProperties.createProp(DeployCreateProperties.java:357) [ebean.jar:na] 
at com.avaje.ebeaninternal.server.deploy.parse.DeployCreateProperties.createProp(DeployCreateProperties.java:377) [ebean.jar:na] 
at com.avaje.ebeaninternal.server.deploy.parse.DeployCreateProperties.createProperties(DeployCreateProperties.java:168) [ebean.jar:na] 
at com.avaje.ebeaninternal.server.deploy.parse.DeployCreateProperties.createProperties(DeployCreateProperties.java:94) [ebean.jar:na] 

私は変更を加えることができますかブロブの種類は認識できますか? >バイト配列なので、多分それは、ファイルシステム内のファイルを保存する方が簡単です - おそらくあなたはファイル<の間で変換する必要がありますあなたが@Lob注釈

@Lob 
public byte[] image; 

でバイト配列を使用する必要がEbeanでblobを作成するには

答えて

10

? (FSにファイルを格納するだけでDBよりも安価です)

特別なアクセス制限が必要な場合は、独自のコントローラを使用してアクセス権をチェックし、DBに格納されたパスでディスクからファイルをストリーミングできます。

+0

ありがとうございました。私はHerokuに「ERROR:type」というブロブが「存在しない」というエラーが1つあります。私は自分の地元で「遊び」を使ってみました。しかし、ヘロクではない。 – angelokh

+0

HerokuはデフォルトでPostgresを使用しています。おそらくあなたはMySQLでlocalyを開発しています(注:私は推測しようとしています)。 Postgres [blobをサポートしていません](http://www.postgresql.org/docs/current/interactive/datatype-binary.html) – biesior

関連する問題