【问题标题】:Mapping BigInteger in YAML file with PlayFramework使用 PlayFramework 在 YAML 文件中映射 BigInteger
【发布时间】:2011-12-08 12:17:28
【问题描述】:

给出以下模型示例:

@Entity
@Table(name="tierenforcers")
public class TierEnforcer extends Model {
    public BigInteger maxStorage; // expressed in B
}

如何在我的 yml 文件中映射 BigInteger?如果我这样做:

TierEnforcer(joeTE):
    maxStorage:             5368709120

#play 测试启动时我没有收到错误,但我的数据库中有一个 NULL 值(BigInteger 在 MySQL 中创建为 decimal(19,2),但将值持久化到其中似乎与 JPA 一起工作正常)

【问题讨论】:

    标签: jpa playframework yaml


    【解决方案1】:

    玩!在引擎盖下使用snakeyml。查看他们的网站了解更多信息。

    查看this yaml example,您可以尝试创建一个 BigInteger,然后将其分配给您的实例

    bigInteger(myBigInt): 123456789012345678901234567890123456789
    
    TierEnforcer(joeTE):
        maxStorage:             myBigInt
    

    希望它有效;)

    【讨论】:

    • 感谢您指出正确的语法。我刚刚尝试了这个并得到了一些不同的东西:Execution exception RuntimeException occured : Cannot load fixture data.yml: java.math.BigInteger cannot be cast to java.util.Map
    • 接受这个答案,因为它让我意识到它无法完成。切换到长....谢谢!
    猜你喜欢
    • 1970-01-01
    • 2019-01-08
    • 2021-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-19
    • 1970-01-01
    相关资源
    最近更新 更多