求大侠帮忙啊 #商品表
create table merchan(
merId int(2) not null primary key  auto_increment,
merName varchar(20) not null,
type_mer_id int(2),
secondType_mer_id int(2),
secondType_mer_id varchar(20),
merPrice decimal(8,2) not null,
merDiscount decimal(2,1),
merPicture varchar(100),
merDesc varchar(500),
merProducter varchar(20),
merLeaveDate timestamp,
merAddDate timestamp,
sellNum int(2),
allNum int(2),
order_mer_id int(2))DEFAULT CHARSET=utf8; 
alter table merchan alter  column merId set default '0';
Merchan.hbm.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping package="com.bean">
    <class name="Merchan" table="merchan" >
        <id name="merId" type="java.lang.Integer" >
            <column name="merId" />
            <!-- 指定使用identity主机生成策略 -->
            <generator class="identity" />
        </id>
        <property name="merName" type="java.lang.String">
            <column name="merName" length="20" not-null="true" />
        </property>
        
        <property name="merPlace" type="java.lang.String">
            <column name="merPlace" length="20" />
        </property>
        <property name="merPrice" type="java.lang.Double">
            <column name="merPrice" precision="8" not-null="true" />
        </property>
        <property name="merDiscount" type="java.lang.Double">
            <column name="merDiscount" precision="2" scale="1" />
        </property>
        <property name="merPicture" type="java.lang.String">
            <column name="merPicture" length="100" />
        </property>
        <property name="merDesc" type="java.lang.String">
            <column name="merDesc" length="500" />
        </property>
        <property name="merProducter" type="java.lang.String">
            <column name="merProducter" length="20" />
        </property>
        <property name="merLeaveDate" type="java.sql.Timestamp" not-null="true">
            <column name="merLeaveDate"  />
        </property>
        <property name="merAddDate" type="java.sql.Timestamp" not-null="true" >
            <column name="merAddDate"   />
        </property>
        <property name="sellNum" type="java.lang.Integer">
            <column name="sellNum" />
        </property>
        <property name="allNum" type="java.lang.Integer">
            <column name="allNum" />
        </property>
        <!-- 配置商品与一级类别之间单向的1-1关系 -->
        <!--<many-to-one>元素增加unique="true"属性就成了1-1  -->
        <many-to-one name="firstType" unique="true" class="FirstType" column="type_mer_id" />
        <!-- 配置商品与二级类别之间单向的1-1关系 -->
        <!--<many-to-one>元素增加unique="true"属性就成了1-1  -->
         <many-to-one name="secondType" unique="true" class="SecondType" column="secondType_mer_id" />
      <!-- 配置商品与订单之间N-1双向关联关系 -->
      <many-to-one name="order" class="Orders" column="order_mer_id"/>
       <!-- 配置商品与评价之间的双向1-N的关系 -->
       <set name="evaluate" table="evaluate" inverse="true " cascade="save-update">
       <key column="mer_eval_id"/>
       <one-to-many class="Evaluate"/>
       
       </set>
       
    </class>
</hibernate-mapping>我在保存对象的时候发生异常提交保存的代码如下:public class MerchanAction extends ActionSupport{

private static final long serialVersionUID = -7546549226738762677L;
private static Logger log=Logger.getLogger(MerchanAction.class); private Map<FirstType,List<SecondType>> merchanMap=new LinkedHashMap<FirstType,List<SecondType>>();//用于存蓄商品
private Integer id;//用于根据商品id删除/查找/更新商品对象
private FirstTypeDao firstTypeDao;//通过依赖方式注入
private SecondTypeDao secondTypeDao;//通过依赖方式注入
private MerchanDao merchanDao;//通过依赖方式注入
private Merchan merchan;//商品对象
    private File file;
    private String fileFileName;
private String key;//商品关键字;
private List<Merchan>merList=new ArrayList<Merchan>();// 商品集合
private String time;//修改前台获取时间


//保存商品对象
@SuppressWarnings("deprecation")
public String execute() throws Exception{
//取得上传图片保存的路径
try{
String targetDirectory=ServletActionContext.getRequest().getRealPath("/upload");
 //修改照片名字  保存照片名字为 System.currentTimeMillis().jpg 
         
         String targetFileName=System.currentTimeMillis()+fileFileName.substring(fileFileName.indexOf("."));
         //生成上传的File对象
         File target = new File(targetDirectory, targetFileName);
         //放在File对象,从而实现上传文件
         FileUtils.copyFile(file, target); 
         //设置图片的地址
         String address="upload"+"/"+targetFileName;
       //  为商品设置图片地址
         merchan.setMerPicture(address);
         //设置商品的添加时间
         try{
         merchan.setMerAddDate(DateTime.getTime());
         }catch(Exception e){
          addActionMessage("是这里错误"+e.getMessage());
         }
         //设置目前的商品销售数量 初始为0
         merchan.setSellNum(0);
         //设置商品出厂时间
                        /*
                         * time.equals( " "))当time为null时抛出NullPointerException. 
                                                                    而( " ").equals(   time   )不会。
                         */
         
         if(("").equals(time)||time==null){
          merchan.setMerLeaveDate(null);
         }else{
         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String sdate=df.format(Date.valueOf(time));
        merchan.setMerLeaveDate(Timestamp.valueOf(sdate)) ;
         }
         merchanDao.save(merchan);
         log.info("商品保存成功"+merchan.getMerName());
}catch(Exception e) {
                e.printStackTrace();
             addActionError("地方"+e.getMessage());
             return "error";
}
return SUCCESS;
}提交页面如下:
<s:form name="mer" action="merchanAction" method="post" theme="simple" onsubmit="return meradd()" enctype="multipart/form-data" >
<table width="736" height="535" border="1" align="center">
  <tr>
    <td height="45" colspan="2" align="center" bgcolor="#999999"><span class="STYLE1">商品添加</span></td>
  </tr>
  <tr>
    <td width="110" height="31" ><span class="STYLE2">*</span>商品类别:</td>
    <td width="251"><div class="doubleselect">    
    <s:doubleselect name="merchan.firstType.typeId" list="merchanMap.keySet()" listKey="typeId" listValue="typeName" doubleName="merchan.secondType.secondTypeId" doubleList="merchanMap[top]" doubleListKey="secondTypeId" doubleListValue="secondTypeName" />
     
      </div>
    </td>
  </tr>
  <tr>
    <td height="35" align=""><span class="STYLE2">*</span>商品名称</td>
    <td><s:textfield name="merchan.merName" id="merName" height="20px"/></td>
  </tr>
  <tr>
    <td height="34">商品出厂地</td>
    <td><s:textfield name="merchan.merPlace" id="merPlace" height="20px"/></td>
  </tr>
  <tr>
    <td height="28">厂家</td>
    <td><s:textfield name="merchan.merProducter" id="merProducter" height="20px"/></td>
  </tr>
  <tr>
    <td height="27" bgcolor="#FFFFFF"><span class="STYLE2">*</span>商品价格</td>
    <td><s:textfield name="merchan.merPrice" id="merPrice" height="20px"/></td>
  </tr>
  <tr>
    <td height="31"><span class="STYLE2">*</span>会员打折</td>
    <td><s:textfield name="merchan.merDiscount" id="merDiscount" height="20px"/>&nbsp;<span class="STYLE2">只能输入(1-9)</span></td>
  </tr>
  <tr>
    <td height="31">商品出厂时间</td>
    <td><s:textfield name="time" id="merLeaveDate" height="20px"/>&nbsp;<span class="STYLE2">按2012-03-21输入</span></td>
  </tr>
  <tr>
    <td height="31"><span class="STYLE2">*</span>商品图片</td>
    <td><s:file name="file" id="merPicture"></s:file>
     
     
    </td>
  </tr>
  <tr>
    <td height="31"><span class="STYLE2">*</span>库存数量</td>
    <td>
      <s:textfield name="merchan.allNum" id="allNum" height="20px"/>    </td>
  </tr>
  <tr>
    <td height="134">商品描述</td>
    <td><s:textarea name="merchan.merDesc" id="merDesc" cols="70" rows="7"/></td>
  </tr>
  <tr>
    <td height="49"><span class="STYLE2">提示:*</span>部分必须填</td>
    <td align="center"><label>
     <s:submit value="提交"/>
      &nbsp;&nbsp; 
      <input type="reset" name="button" id="button" value="重置" /> 
    </label></td>
  </tr>
</table>
</s:form>