开发者

Array[Byte] in Play Framework model

I would like to ask you a question about byte array being part of the play framework model. My model is defined like this:

@Entity
class BTFile (
  @Required
  var hash : Array[Byte],

  @Required
  var size : Int

) extends Mode开发者_JS百科l {

  @OneToMany(mappedBy="file",cascade=Array(CascadeType.ALL))
  var peers:JList[BTPeer] = new ArrayList[BTPeer]
}

With DAO object defined as

object BTFiles extends QueryOn[BTFile]

But every time i try to use BTFiles.find("byHash"), it throws following exception:

[B cannot be cast to [Ljava.lang.Object;

Does anyone know how to fix this issue? I tried to google it up but i found no solution. The unit test i test it in:

 it should "create and retrieve BTFile" in {
   val file = new BTFile("some_hash".getBytes,1).save

   BTFiles.find("byHash","some_hash".getBytes)

 }

Any help would be appreciated!


I suggest you try using java.lang.Byte, since Array is not type erased, and, therefore, and Array[Byte] cannot be cast into an Array[Object].

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜