English 中文(简体)
荣誉:创始:浮动,预期:双重精确度
原标题:Hibernate: Found: float, expected: double precision

我在把Oracle Float双重精确数据类型绘制为 Java双重数据类型方面有问题。 当使用 Java双重数据类型时,保密的化学验证器似乎失败。

org.hibernate.HibernateException: Wrong column type in DB.TABLE for column amount. Found: float, expected: double precision

避免这种情况的唯一途径是进行不可行的chem化鉴定,希望chem与 app合。 必须在生产前确定。

App s evironment:
- Grails 1.2.1
- Hibernate-core 3.3.1.GA
- Oracle 10g

最佳回答

更需要信息。 表格是双重的? 我不熟悉Oracle,而是一个浮动点? The java.sql. 类型: 它的类型? 查阅java.sql.Types,以便输入贵国数据库的方言类别数据库。 此处为org.hibernate.dialect.Oracle10gDialect(延伸9i和8i)。 你们喜欢

registerColumnType( Types.DOUBLE, "double precision" );

因此,表格必须定义为<条码>双倍精度,java类必须定义为将测绘成<条码>的表格。

从错误的电文中,它看上去像您的表被定义为float,该表将使用这一制图。

registerColumnType( Types.FLOAT, "float" );

预期的java型号是的地图。 类型.FLOAT,通常float;单一精确值。

最容易做的事情是改变你的桌子或 j子,使之符合要求。 或者,你可以具体说明一种用户类型,将单一精确值描绘成双重精确值;我想到,为什么你真的想要这样做,但也许如果你对这个类别和表格都控制,我会认为,这非常少见。

hth。

问题回答

除非您在DDL文档中将一栏类型定义为double±/code>,否则甲骨文将改为float一栏。 因此,你需要在方言类别中登记双倍为浮动列。

public class Oracle10gDialectExtended extends Oracle10gDialect {

    public Oracle10gDialectExtended() {
        super();
        registerColumnType(Types.DOUBLE, "float");
    }
}

最后,在Hibernate/JPA配置中,“Oracle10gDialectEx 预期hibernate.dialect

如果你使用通知方法,你需要宣布外地的栏目类型如下。

@Column(name = "PERFORMANCE", columnDefinition = "FLOAT(5,2)")
private double performance;

我们有同样的问题。 我们解决了这一问题,确保像以下那样明确绘制地图中的一栏:

<property name="performance" type="double">
  <column name="PERFORMANCE" sql-type="float" />
</property>

适用情况:执行

hibernate.dialect=com.test.config.Oracle10gDialectEx 预期

创作品

package com.test.config;

import java.sql.Types;

import org.hibernate.dialect.Oracle10gDialect;

public class Oracle10gDialectExtended extends Oracle10gDialect {

    public Oracle10gDialectExtended() {
        registerColumnType(Types.DOUBLE, "float");
    }
}

我的甲骨文一栏类型为NUMBER, Java的类型为double

最后,它追溯到环境

<property name=“hbm2dl.auto”>validate</property>

刚才改为

<property name=“hbm2dl.auto”>update</property>

一切工作!

经过大量研究并尝试找到解决办法。 对于铁路领域,我们可以通过增加sql来解决这一问题。 认证模式的“float” /strong。

http://www.ohchr.org。

class Result{
    Double discount

    static mapping = {
        discount column: "discount", sqlType: "float"
    }

    static constraints = {
        discount(nullable: true)
    }
}

因此,它将消除验证方式中的错误。

我在迁移一艘四轮船时就曾有过这个问题。 Rob Keilty的一项建议是,将hbm2dl.auto从认证改为更新,而不必修改遗产法典。





相关问题
Multiple Hibernate instances using C3P0

I am facing a weird problem and it seems to be c3p0 related. I am starting two instances of an app in the same java vm which interact with each other. After some operations "APPARENT DEADLOCK" ...

Hibernate vs Ibatis caching

We can speed up a hibernate app easyly with 2nd level cache using infinispan or ehcache/terracotta,... but ibatis only have a simple interface to implement for caching. And hibernate knows more ...

Using annotations to implement a static join in hibernate

I m relatively new to hibernate and was wondering if someone could help me out. While I have no issues implementing a normal join on multiple columns in hibernate using the @JoinColumns tag, I m ...

Hibernate query with fetch question

I have a 2 entities in a One-To-Many relationship: OfficeView.java: public class OfficeView implements java.io.Serializable { private Integer officeId; private String addr1; private ...

hibernate interceptors : afterTransactionCompletion

I wrote a Hibernate interceptor : public class MyInterceptor extends EmptyInterceptor { private boolean isCanal=false; public boolean onSave(Object entity, Serializable arg1, Object[] arg2, String[]...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

Hibernate/GORM: collection was not processed by flush()

I have an integration test in my Grails application that fails when I try to save an entity of type Member invitingMember.save(flush: true) This raises the following exception org.hibernate....

Hibernate Criteria API equivalent for "elements()"

Is it possible to implement the following query using Criteria API? select order from ORDER as order,ITEM as item where item.itemID like ITM_01 and item in elements(order.items)