-->
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.  [ 1 post ] 
Author Message
 Post subject: Probleme de ClassCastException avec Character et un String
PostPosted: Fri Aug 20, 2010 5:40 pm 
Regular
Regular

Joined: Wed Jan 28, 2009 8:31 pm
Posts: 54
Bonjour a tous
j ai un trouble de probleme de ClassCastException envers un
et un String voici mon dao
Code:
public List<TprchsSaleTrans> findTprchsSaleTrans()
{
  List<Object> l = null;
  TprchsSaleTrans prchsSaleTrans = null;
  List<TprchsSaleTrans> listReturn = new ArrayList<TprchsSaleTrans>();
try {
l = this.getHibernateTemplate().[B]findByNamedQuery[/B("tprchsSaleTransQuery");
for (Object list : l)
{
    Object[] element = (Object[]) list;
    prchsSaleTrans = new TprchsSaleTrans();
    prchsSaleTrans.setTprchssaletransID((Integer) element[0]);
      //dans la bd BranchCd = 199 et hibernate me sort seulement le 1 char
     [B]prchsSaleTrans.setBranchCd((String) element[1]);[/B]
listReturn.add(prchsSaleTrans);......
         }
      } catch (Exception e) {
         e.printStackTrace();
      }
      return listReturn;
   }
}

mon mapping
Code:
<hibernate-mapping>
    <class name="TprchsSaleTrans" table="tprchs_sale_trans">
         <id name="tprchssaletransID" type="java.lang.Integer">
            <column name="tprchs_sale_trans_ID" />
            <generator class="identity" />
        </id>
            <property name="accountCd" type="string">
                <column name="account_cd" length="5" />
            </property>
            [B]<property name="branchCd" type="string">
                <column name="branch_cd" length="3" />
            </property>[/B]....
</class>
    [B] <sql-query name="tprchsSaleTransQuery">
      <![CDATA[select tprchs_sale_trans_ID,branch_cd,account_cd,type_account_cd,chck_brch_acct_nbr, transaction_dt,currency_cd,sum(case when debit_credit_cd = 'C' then tran_total_amt * -1 else tran_total_amt  end) as net FROM tprchs_sale_trans where  CONVERT(varchar(20), transaction_dt,105 )   = CONVERT(varchar(20),GETDATE(),105) or (CONVERT(varchar(20), processing_dt,105 )   = CONVERT(varchar(20),GETDATE()-1,105) and  transaction_dt  <=   GETDATE() ) GROUP by branch_cd,account_cd,type_account_cd,chck_brch_acct_nbr,transaction_dt,currency_cd,tprchs_sale_trans_ID]]>
   </sql-query>[/B]
</hibernate-mapping>

et dans mon pojo
Code:
private String branchCd;
bien sur un String
et pour finir la declaration dans la bd
branch_cd char size= 3

je comprends vraiment pas pourquoi hibernate me sort un char!!
Est ce qu ily a quelqu un qui peut m aider svp


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

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.