ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brandon Goodin" <brandon.goo...@gmail.com>
Subject Re: [ibatis2]can I use a class with inner classes as resultMap?
Date Wed, 01 Aug 2007 07:38:47 GMT
I'm not seeing where you initialize your inner classes. All I see is the
following...

 private IconStyle iconStyle;
 private LableStyle lableStyle;
 private LineStyle lineStyle;

They would be null at this point.

Brandon

On 7/31/07, 钟原froast <froast@gmail.com> wrote:
>
> hi, I have a class like this:
>
> package com.gehouse.bean.ge;
>
> public class GEElementStyleBean {
>
>
>  public class IconStyle {
>   int id;
>   float scale;
>   boolean transparent;
>   public int getId() {
>    return id;
>   }
>   public void setId(int id) {
>    this.id = id;
>   }
>   public float getScale() {
>    return scale;
>   }
>   public void setScale(float scale) {
>    this.scale = scale;
>   }
>   public boolean isTransparent() {
>    return transparent;
>   }
>   public void setTransparent(boolean transparent) {
>    this.transparent = transparent;
>   }
>  }
>
>  public class LableStyle {
>   String color;
>   float scale;
>   public String getColor() {
>    return color;
>   }
>   public void setColor(String color) {
>    this.color = color;
>   }
>   public float getScale() {
>    return scale;
>   }
>   public void setScale(float scale) {
>    this.scale = scale;
>   }
>  }
>
>  public class LineStyle {
>   String color;
>   float scale;
>   public String getColor() {
>    return color;
>   }
>   public void setColor(String color) {
>    this.color = color;
>   }
>   public float getScale() {
>    return scale;
>   }
>   public void setScale(float scale) {
>    this.scale = scale;
>   }
>  }
>
>  private IconStyle iconStyle;
>  private LableStyle lableStyle;
>  private LineStyle lineStyle;
>
>  public IconStyle getIconStyle() {
>   return iconStyle;
>  }
>
>  public void setIconStyle(IconStyle iconStyle) {
>   this.iconStyle = iconStyle;
>  }
>
>  public LableStyle getLableStyle() {
>   return lableStyle;
>  }
>
>  public void setLableStyle(LableStyle lableStyle) {
>   this.lableStyle = lableStyle;
>  }
>
>  public LineStyle getLineStyle() {
>   return lineStyle;
>  }
>
>  public void setLineStyle(LineStyle lineStyle) {
>   this.lineStyle = lineStyle;
>  }
> }
> -----------------------------------------------------------------------------------------------------------------
>
>
> and result map like this:
>
> <typeAlias alias="GEStyle" type="com.gehouse.bean.ge.GEElementStyleMapBean
> "></typeAlias>
>  <typeAlias alias="GEElementStyle" type="
> com.gehouse.bean.ge.GEElementStyleBean "></typeAlias>
>
>  <resultMap id="GEStyleResultMap" class="GEStyle">
>    <result property="id" column="id"/>
>    <result property="name" column="name"/>
>
>    <result property="normalStyle.iconStyle.id" column="nomal_icon_id"/>
>    <result property="normalStyle.iconStyle.scale"
> column="normal_icon_scale"/>
>    <result property="normalStyle.iconStyle.transparent"
> column="normal_icon_transprent"/>
>    <result property="normalStyle.lableStyle.color"
> column="normal_label_color"/>
>    <result property="normalStyle.lableStyle.scale"
> column="normal_label_scale"/>
>    <result property="normalStyle.lineStyle.color"
> column="normal_line_color"/>
>    <result property="normalStyle.lineStyle.scale"
> column="normal_line_width"/>
>
>    <result property="highlightStyle.iconStyle.id"
> column="highlight_icon_id"/>
>    <result property="highlightStyle.iconStyle.scale"
> column="highlight_icon_scale"/>
>    <result property="highlightStyle.iconStyle.transparent"
> column="highlight_icon_transprent"/>
>    <result property="highlightStyle.lableStyle.color"
> column="highlight_label_color"/>
>    <result property="highlightStyle.lableStyle.scale"
> column="highlight_label_scale"/>
>    <result property="highlightStyle.lineStyle.color"
> column="highlight_line_color"/>
>    <result property="highlightStyle.lineStyle.scale"
> column="highlight_line_width"/>
>
>   </resultMap>
>
>
> --------------------------------------------------------------------------------------------------------------
>
> but it throws exceptions, saying that normalStyle.iconStyle is null, all
> the inner class objects are null, the ibatis can't initialize the object.
>
> is there any solutions? any help would be appreciated.
>
Mime
View raw message