查看你的 
hibernate.cfg.xml 的 <mapping resource="ch03/hibernate/User.hbm.xml"/>
中的这句话 。
ch03/hibernate/User.hbm.xml 是否真的是这个路径 ,还是根本就没有配这个节点。如果还不是
看你 User.hbm.xml  是 <property type="Integer"> ]
你是否配了一个类型为 Integer 的 如果是:
改成 java.lang.Integer 或  integer

解决方案 »

  1.   

    ---------------------------------------------------------User.hbm.xml
    <?xml version="1.0" encoding="UTF-8"?> 
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> 
    <hibernate-mapping> 
    <class name="ch03.hibernate.User" table="myusertable"> 
    <id column="id" length="10" name="id" type="Integer"> 
    <generator class="uuid.hex"/> 
    </id> 
    <property column="username" length="16" name="username" not-null="false" type="string"/> 
    <property column="password" length="16" name="password" not-null="false" type="string"/> 
    <property column="email" length="16" name="email" not-null="false" type="string"/> 
    <!--<property column="lastlogin" length="7" name="lastlogin" type="calendar"/>--> 
    </class> 
    </hibernate-mapping> 
    --------------------------------------------------------------------hibernate.cgf.xml
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
              "-//Hibernate/Hibernate Configuration DTD 2.0//EN"
              "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd"><!-- Generated by MyEclipse Hibernate Tools.                   -->
    <hibernate-configuration>    <session-factory>
            <property name="connection.username">root</property>
            <property name="connection.url">jdbc:mysql://localhost:3306/myproject</property>
            <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
            <property name="myeclipse.connection.profile">db</property>
            <property name="connection.password">root</property>
            <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
            
            <property name="connection.pool.size">1</property> 
    <property name="statement_cache.size">25</property> 
    <property name="jdbc.fetch_size">50</property> 
    <property name="jdbc.batch_size">30</property> 
    <property name="show_sql">true</property>
    <property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
         <mapping resource="ch03/hibernate/User.hbm.xml"></mapping>
        
    <!-- <mapping resource="Add valid path"/> -->
        </session-factory></hibernate-configuration>这是我的配制文件我还是找不到问题所在.谢谢各位!
      

  2.   

    看你的<id column="id" length="10" name="id" type="Integer">  我上面都给你猜出来了。 i  小写。
      

  3.   

    我用mysql数据库,表中id为int(10),name为varchar(16),其他字段不说了;这是javabean里的内容:
    private int id;
    private String username;
    private String password;
    private String email;
    public int getId() {
    return id;
    }
    public void setId(int id) {
    this.id = id;
    }
    public String getEmail() {
    return email;
    }
    public void setEmail(String email) {
    this.email = email;
    }
    public String getPassword() {
    return password;
    }
    public void setPassword(String password) {
    this.password = password;
    }
    public String getUsername() {
    return username;
    }
    public void setUsername(String username) {
    this.username = username;
    }
    现在的错误是:
    6   [main] DEBUG net.sf.ehcache.config.Configuration$DiskStore(182) - Disk Store Path: C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\
    547  [main] ERROR net.sf.hibernate.property.BasicPropertyAccessor(60) - IllegalArgumentException in class: ch03.hibernate.User, setter method of property: id
    547  [main] ERROR net.sf.hibernate.property.BasicPropertyAccessor(64) - expected type: int, actual value: java.lang.String
    net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of ch03.hibernate.User.id
    at net.sf.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:68)
    at net.sf.hibernate.persister.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:337)
    at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:855)
    at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:790)
    at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:749)
    at ch03.hibernate.Test.main(Test.java:23)
    Caused by: java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at net.sf.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:38)
    ... 5 more
    在帮一下忙,不剩感激,我请你吃大餐
      

  4.   

    uuid.hex这个只能用于String吧我要没记错的话你的id是Integer的
      

  5.   

    [color=#FF0000][/太谢谢你们了我改成功了color]