此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【yeaea】截止到2008-07-30 18:10:27的历史汇总数据(不包括此帖):
发帖的总数量:0                        发帖的总分数:0                        每贴平均分数:0                        
回帖的总数量:0                        得分贴总数量:0                        回帖的得分率:0%                       
结贴的总数量:0                        结贴的总分数:0                        
无满意结贴数:0                        无满意结贴分:0                        
未结的帖子数:0                        未结的总分数:0                        
结贴的百分比:---------------------结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html

取消马甲机器人,请点这里:http://www.java2000.net/mycsdn/robotStop.jsp?usern=yeaea

解决方案 »

  1.   

    数据库中数据类型为date不能精确到时分秒的!
      

  2.   

    你的po定义的是date类型么?
    你怎么格式化的?
      

  3.   

    代码太长,多余的删掉了
    po代码:
    package cn.com.cssnj.ntsh.po;import java.util.Date;/**
     * TFpHyyzkprdb generated by MyEclipse Persistence Tools
     */public class TFpHyyzkprdb implements java.io.Serializable { /**
     * 
     */
    private static final long serialVersionUID = 1L; // Fields
    private Date yyzhfzrq; private Date swdjzrq;
    // Constructors /** default constructor */
    public TFpHyyzkprdb() {
    } /** minimal constructor */
    public TFpHyyzkprdb(String gzlh) {
    this.gzlh = gzlh;
    } /** full constructor */
    public TFpHyyzkprdb(String gzlh, String wjdm, String nsrsbh, String jjxz,
    String bsrmc, String frmc, String frsfzh, String lxdh, String yhzh,
    String khyh, String idKhyh, String yyzzhm, Date yyzhfzrq,
    Date swdjzrq, String swdjzhm, String dlysjyxkzh, String slysjyxkzh,
    Double ntghylwje, String zbysgj, String zyhzybgdzjzq,
    String zbszzlmc, Integer snfpsyl, String nsrsqyj, String jbr,
    String fzr, Date sqrq, String submitFlag, Date lrsj, String nsrmc) {
    this.gzlh = gzlh;
    this.wjdm = wjdm;
    this.nsrsbh = nsrsbh;
    this.jjxz = jjxz;
    this.bsrmc = bsrmc;
    this.frmc = frmc;
    this.frsfzh = frsfzh;
    this.lxdh = lxdh;
    this.yhzh = yhzh;
    this.khyh = khyh;
    this.idKhyh = idKhyh;
    this.yyzzhm = yyzzhm;
    this.yyzhfzrq = yyzhfzrq;
    this.swdjzrq = swdjzrq;
    this.swdjzhm = swdjzhm;
    this.dlysjyxkzh = dlysjyxkzh;
    this.slysjyxkzh = slysjyxkzh;
    this.ntghylwje = ntghylwje;
    this.zbysgj = zbysgj;
    this.zyhzybgdzjzq = zyhzybgdzjzq;
    this.zbszzlmc = zbszzlmc;
    this.snfpsyl = snfpsyl;
    this.nsrsqyj = nsrsqyj;
    this.jbr = jbr;
    this.fzr = fzr;
    this.sqrq = sqrq;
    this.submitFlag = submitFlag;
    this.lrsj = lrsj;
    this.nsrmc = nsrmc;
    } // Property accessors public Date getYyzhfzrq() {
    return this.yyzhfzrq;
    } public void setYyzhfzrq(Date yyzhfzrq) {
    this.yyzhfzrq = yyzhfzrq;
    } public Date getSwdjzrq() {
    return this.swdjzrq;
    } public void setSwdjzrq(Date swdjzrq) {
    this.swdjzrq = swdjzrq;
    }

    ////////////////////////////////////////////////////////////////
    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>
        <class name="cn.com.cssnj.ntsh.po.TFpHyyzkprdb" table="t_fp_hyyzkprdb" schema="dbo" catalog="nsfw">
            <id name="gzlh" type="java.lang.String">
                <column name="GZLH" length="21" />
                <generator class="assigned" />
            </id>
            <property name="yyzhfzrq" type="java.util.Date">
                <column name="YYZHFZRQ" length="10" />
            </property>
            <property name="swdjzrq" type="java.util.Date">
                <column name="SWDJZRQ" length="10" />
            </property>
        </class>
    </hibernate-mapping>
      

  4.   

    调用在这里:
    import java.util.Date;
    import cn.com.cssnj.ntsh.po.TFpHyyzkprdb;TFpHyyzkprdb po = null;
    po = (TFpHyyzkprdb)this.ihibernatedao.findByPk("cn.com.cssnj.ntsh.po.TFpHyyzkprdb", gzlh);
    //////////////////////////
    /**
     * 根据对象键值返回对象实例。
     */
    public Object findByPk(String className, Serializable pk) throws Exception {
    LogUtil.debug("getting obj instance with pk: ");
    try {
    Object instance = (Object) getHibernateTemplate()
    .get(className, pk);
    return instance;
    } catch (RuntimeException re) {
    LogUtil.error("get failed", re.fillInStackTrace());
    throw re;
    }
    }
      

  5.   

    timestamp,好像是有时分秒的哦。
      

  6.   

    timestamp是有时分秒的没错
    但是我数据库中存的是date型
    po中定义的也是date型,为什么取出来是一个与date值都不符的timestamp呢
    迷糊!
      

  7.   

    java.util.Date好像要自己写一个格式转换器,
    java.sql.Date就不用,hibernate里有这个日期类的转换器。
      

  8.   

    很可能是17楼所说的时区问题,如果你服务器是在一个windows域中,那么时区往往存在bug,需要把时区选择的界面打开,确认选择东八区,并一定要按一下“确定”按钮,我以前也碰到过时区导致的问题。不过楼主的问题请先查看一下是否每次都必定早八个小时
      

  9.   

    java.util.Date是java.sql.Timestamp的父类,事实上jdbc驱动程序都是用Timestamp作为日期的具体实现类的。
    也请检查一下是否日期格式化的时候有误,我以前写过这种日期格式:yyyy-MM-dd HH:mm:ss ms,看出来了吗?最后的ms是不对的,我这样导致了日期最后秒数不正确的情况,查了好久才发现问题