PostgreSQL 不喜欢 double 类型的列

标签 postgresql heroku playframework-2.0

我有一个 Play 2.0 应用程序,我正试图将其部署到 Heroku。在成功编译并在本地主机上运行后,Heroku 提示类型“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 类型的列有关。

最佳答案

不确定您的 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;

关于PostgreSQL 不喜欢 double 类型的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18219356/

相关文章:

macos - 引导后运行的恶意 postgres 进程

sql - 在 Heroku Postgresql DB 中创建模式

ruby-on-rails-3 - PGError : Error: column of relation does not exist

javascript - 如何使用 java 脚本 window.location 将参数传递给 play 框架中的 java 方法?

java - 如何从 Java 停止 Play Framework

playframework-2.0 - 在Scala模板中打印HTML

postgresql - 在 postgresql/PL/pgSQL 中创建函数时同时更新元组

javascript - 使用 Leafletjs 显示 PostGIS 数据

sql - POSTGRESQL 如何将子表的行插入到父表的数组中

bash - 无法在 heroku 上获取 jenkins 的 initialAdminPassword