PostgreSQL不喜欢double类型的列

时间:2013-08-13 21:15:52

标签: postgresql heroku playframework-2.0

我有一个Play 2.0应用程序,我正在尝试部署到Heroku。在成功编译并在localhost上运行后,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();
    }

}

我认为它与使用 double 类型的列生成SQL的PostgreSQL驱动程序有关,而不是双精度

1 个答案:

答案 0 :(得分:2)

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