【问题标题】:PostgreSQL doesn't like columns of type doublePostgreSQL 不喜欢 double 类型的列
【发布时间】:2013-08-15 16:12:03
【问题描述】:

我有一个尝试部署到 Heroku 的 Play 2.0 应用程序。在成功编译并在 localhost 上运行后,Heroku 抱怨 type "double" 不存在。该应用程序本身与此处的 JavaTodoList 教程极为相似:

http://www.playframework.com/documentation/2.0/JavaTodoList

除了模型有 Double 字段,而不是 String 字段,像这样:

package models;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Id;

import play.data.validation.Constraints.Required;
import play.db.ebean.Model;

@SuppressWarnings("serial")
@Entity
public class GeoPoint extends Model {

    @Id
    public Long id;

    @Required
    public Double latitude;

    @Required
    public Double longitude;

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public static Finder<Long, GeoPoint> find = new Finder(Long.class, GeoPoint.class);

    public static List<GeoPoint> all() {
        return find.all();
    }

    public static void create(GeoPoint task) {
        task.save();
    }

    public static void delete(Long id) {
        find.ref(id).delete();
    }

}

我相信这与 PostgreSQL 驱动程序生成 SQL 的类型为 double 而不是 double precision 的列有关。

【问题讨论】:

    标签: postgresql heroku playframework-2.0


    【解决方案1】:

    不确定您的 ORM 是什么,但我们正在 heroku 上运行 ebean。

    这就是我们精确处理数字的方式

    @Entity
    @Table(name = "e_company_billing_contract_item")
       public class CompanyBillingContractItem extends GenericDBO{
       @JsonIgnore
       @ManyToOne
       private CompanyBillingContract contract;
       private String name;
       private int nbrIncluded;
       private int maxLimit;
       @Column(columnDefinition = "NUMERIC")
       private BigDecimal price;
    

    【讨论】:

    • 抱歉回复晚了,但专栏正是我所需要的。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-23
    • 2018-06-26
    • 1970-01-01
    相关资源
    最近更新 更多