我有一个 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/