-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Problems with BigDecimal in PK
PostPosted: Wed Mar 17, 2004 7:45 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
I'm using Hibernate 2.1.1.
When I execute the code below I get the following error:

Code:
WARN : SQL Error: 0, SQLState: null
ERROR: ERROR:  Unable to identify an operator '=' for types 'numeric' and 'double precision'
   You will have to retype this query using an explicit cast

WARN : SQL Error: 0, SQLState: null
ERROR: ERROR:  Unable to identify an operator '=' for types 'numeric' and 'double precision'
   You will have to retype this query using an explicit cast

ERROR: could not load: [vo.ProdutoDadosProducao#vo.ProdutoDadosProducaoPK@543cb1[diametroNominal=10.00,equipProd=vo.EquipProd@120b2da[id=1],produto=vo.Produto@1be4663[id=1]]]
java.sql.SQLException: ERROR:  Unable to identify an operator '=' for types 'numeric' and 'double precision'
   You will have to retype this query using an explicit cast

   at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:131)
( ... )



Can someone please help me?
Don't know what to do...

----------------------------------------
Mapping file (generated with R3)
----------------------------------------

ProdutoDadosProducao
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
   
<hibernate-mapping>

<class
    name="vo.ProdutoDadosProducao"
    table="produto_dados_producao"
>

    <composite-id name="comp_id" class="vo.ProdutoDadosProducaoPK">
        <key-property
            name="diametroNominal"
            column="diametro_nominal"
            type="java.math.BigDecimal"
            length="10"
        />
        <!-- bi-directional many-to-one association to EquipProd -->
        <key-many-to-one
           name="equipProd"
           class="vo.EquipProd"
       >
           <column name="equip_prod_fk" />
       </key-many-to-one>
        <!-- bi-directional many-to-one association to Produto -->
        <key-many-to-one
           name="produto"
           class="vo.Produto"
       >
           <column name="produto_fk" />
       </key-many-to-one>
    </composite-id>   

    <property
        name="debito"
        type="java.math.BigDecimal"
        column="debito"
        length="10"
    />
    <property
        name="userId"
        type="java.lang.String"
        column="user_id"
        not-null="true"
        length="10"
    />

    <!-- associations -->

</class>
</hibernate-mapping>


----------
Code
----------

Code:
( ... )
res = session.find("select pdp.comp_id.diametroNominal, pdp.comp_id.equipProd.id, pdp.comp_id.produto.id from vo.ProdutoDadosProducao pdp where pdp.comp_id.equipProd = ? and pdp.comp_id.produto = ?",
         new Object[] {equip_prod_id, produto_id}, new Type[] {Hibernate.LONG, Hibernate.LONG});
         
Iterator it = res.iterator();
while(it.hasNext()) {
   Object[] obj = (Object[])it.next();
            
   ProdutoDadosProducaoPK dado_producao_pk = new ProdutoDadosProducaoPK();
   EquipProd equip_prod = new EquipProd();
   equip_prod.setId((Long)obj[1]);
   dado_producao_pk.setEquipProd(equip_prod);
   Produto produto = new Produto();
   produto.setId((Long)obj[2]);
   dado_producao_pk.setProduto(produto);
   dado_producao_pk.setDiametroNominal((BigDecimal)obj[0]);
            
   ProdutoDadosProducao dado_producao = (ProdutoDadosProducao)session.get(ProdutoDadosProducao.class, dado_producao_pk);
            
   session.delete(dado_producao);   
}
         
transaction.commit();
( ... )


Top
 Profile  
 
 Post subject: Re: Problems with BigDecimal in PK
PostPosted: Wed Mar 17, 2004 11:20 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
Someone plese help!
I'm stuck.

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 17, 2004 11:27 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Ummmm. Unless I'm very much mistaken, this problem is not Hibernate-related?

Why don't you solve the postgres problem using direct JDBC first, then the Hibernate solution will be obvious.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 17, 2004 11:32 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
gavin wrote:
Ummmm. Unless I'm very much mistaken, this problem is not Hibernate-related?

Why don't you solve the postgres problem using direct JDBC first, then the Hibernate solution will be obvious.


I've made methods to insert, update and delete theses objects and they are working great.

I'm only having problems with this kind of method. A method for bulk delete's.
My guess has to do with the "select" clause. Maybe there's a problem with BigDecimal's in the "select"...


Any ideas?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.