2012-03-15 4 views
2

hibernateを使用するJSFアプリケーションがあります。
ポリゴンのポイントをロードしてポイントを更新したい。hibernateオブジェクトの更新時にデータ型nvarcharを10進数のエラーに変換中にエラーが発生しました

私は、ポイント情報を更新するが、私は変更をコミットしようとしたとき、私は次のエラーを取得する:

WARNING: SQL Error: 8114, SQLState: S0005 
    SEVERE: Error converting data type nvarchar to decimal. 
    SEVERE: Could not synchronize database state with session 
    org.hibernate.exception.SQLGrammarException: could not update: [hibernate.TbPolygonPoint#937] 
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67) 

私は混乱しています、私はオブジェクト内の任意の文字情報を持っていないので、私がしようとしています更新する。

このエラーが発生する理由は誰にも分かりますが、どのように解決できますか?おかげさまで

ここに更新コードがあります。コミットしようとするとエラーが表示されます。

ここにオブジェクトのJavaコードがあります。

import java.math.BigDecimal; 
    import java.util.HashSet; 
    import java.util.Set; 

    /** 
    * TbPolygonPoint generated by hbm2java 
    */ 
    public class TbPolygonPoint implements java.io.Serializable { 


     private long biPolygonPointId; 
     private TbPolygonLoadFile tbPolygonLoadFile; 
     private int isuperGroupId; 
     private int igroupId; 
     private BigDecimal dcLatitude; 
     private BigDecimal dcLongitude; 
     private Set<TbPolygonHasPoints> tbPolygonHasPointses = new HashSet<TbPolygonHasPoints>(0); 

     public TbPolygonPoint() { 
     } 


     public TbPolygonPoint(long biPolygonPointId, int isuperGroupId, int igroupId, BigDecimal dcLatitude, BigDecimal dcLongitude) { 
      this.biPolygonPointId = biPolygonPointId; 
      this.isuperGroupId = isuperGroupId; 
      this.igroupId = igroupId; 
      this.dcLatitude = dcLatitude; 
      this.dcLongitude = dcLongitude; 
     } 
     public TbPolygonPoint(long biPolygonPointId, TbPolygonLoadFile tbPolygonLoadFile, int isuperGroupId, int igroupId, BigDecimal dcLatitude, BigDecimal dcLongitude, Set<TbPolygonHasPoints> tbPolygonHasPointses) { 
     this.biPolygonPointId = biPolygonPointId; 
     this.tbPolygonLoadFile = tbPolygonLoadFile; 
     this.isuperGroupId = isuperGroupId; 
     this.igroupId = igroupId; 
     this.dcLatitude = dcLatitude; 
     this.dcLongitude = dcLongitude; 
     this.tbPolygonHasPointses = tbPolygonHasPointses; 
     } 

     public long getBiPolygonPointId() { 
      return this.biPolygonPointId; 
     } 

     public void setBiPolygonPointId(long biPolygonPointId) { 
      this.biPolygonPointId = biPolygonPointId; 
     } 
     public TbPolygonLoadFile getTbPolygonLoadFile() { 
      return this.tbPolygonLoadFile; 
     } 

     public void setTbPolygonLoadFile(TbPolygonLoadFile tbPolygonLoadFile) { 
      this.tbPolygonLoadFile = tbPolygonLoadFile; 
     } 
     public int getIsuperGroupId() { 
      return this.isuperGroupId; 
     } 

     public void setIsuperGroupId(int isuperGroupId) { 
      this.isuperGroupId = isuperGroupId; 
     } 
     public int getIgroupId() { 
      return this.igroupId; 
     } 

     public void setIgroupId(int igroupId) { 
      this.igroupId = igroupId; 
     } 
     public BigDecimal getDcLatitude() { 
      return this.dcLatitude; 
     } 

     public void setDcLatitude(BigDecimal dcLatitude) { 
      this.dcLatitude = dcLatitude; 
     } 
     public BigDecimal getDcLongitude() { 
      return this.dcLongitude; 
     } 

     public void setDcLongitude(BigDecimal dcLongitude) { 
      this.dcLongitude = dcLongitude; 
     } 
     public Set<TbPolygonHasPoints> getTbPolygonHasPointses() { 
      return this.tbPolygonHasPointses; 
     } 

     public void setTbPolygonHasPointses(Set<TbPolygonHasPoints> tbPolygonHasPointses) { 
      this.tbPolygonHasPointses = tbPolygonHasPointses; 
     } 
    } 

答えて

8

私はここに答えが見つかりました:

http://dertompson.com/2008/01/03/bigdecimal-and-jdbc-since-java-5-0-2/

はどうやら変換プロセスは、小数点の後ろにあまりにも多くの値が含まれていてもよい文字列に二重に変換します。これはBigDecimalに変換されます。この変換プロセスは、エラーの原因となります。

decimalFormat()を使用して、私が望む有効桁数を保持し、その文字列を新しいBigDecimal()変換で使用することでこれを解決しました。


2014年8月20日edejong:旧URLは、死んでいたが、新しいURL

に書き直しました
関連する問題