日期:2014-05-18  浏览次数:20661 次

[100分]求救Hibernate映射配置问题!
我是用了Eclipse3.1   +   MyEclipse4.1让Hibernate插件自动创建映射文件和类文件。
但是不知道为什么老是抱错:
org.hibernate.DuplicateMappingException:   Duplicate   collection   role   mapping   chat.hibernate.pojo.User.chatDatas

具体配置:
////////////////////////////////////////////////////////////////////
我的数据库建表语句如下:

create   table   USER(
id number(10)   primary   key,
name   varchar2(30)   not   null,
password varchar2(30) null
);

create   table   CHAT_DATA(
id number(10)   primary   key,
userid number(10) references   USER(id),
data varchar2(4000) null,
time date
);

////////////////////////////////////////////////////////////////////////////////
hibernate.cfg.xml文件配置如下:

<?xml   version= '1.0 '   encoding= 'UTF-8 '?>
<!DOCTYPE   hibernate-configuration   PUBLIC
                    "-//Hibernate/Hibernate   Configuration   DTD   3.0//EN "
                    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd ">

<!--   Generated   by   MyEclipse   Hibernate   Tools.                                       -->
<hibernate-configuration>

<session-factory>
<property   name= "connection.username "> vickcy </property>
<property   name= "connection.url "> jdbc:pointbase:server://localhost/chat </property>
<property   name= "dialect "> org.hibernate.dialect.PointbaseDialect </property>
<property   name= "myeclipse.connection.profile "> chat </property>
<property   name= "connection.password "> vickcy </property>
<property  

name= "connection.driver_class "> com.pointbase.jdbc.jdbcUniversalDriver </property>

<mapping   resource= "chat/hibernate/pojo/User.hbm.xml "> </mapping>
<mapping   resource= "chat/hibernate/pojo/ChatData.hbm.xml "> </mapping>

</session-factory>

</hibernate-configuration>

/////////////////////////////////////////////////////////////////////////////////////////
User.hbm.xml   文件配置如下:

<!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   -   Hibernate   Tools
-->
<hibernate-mapping>
        <class   name= "chat.hibernate.pojo.User "   table= "USER ">
                <id   name= "id "   type= "java.lang.Long ">
                        <column   name= "ID "   precision= "10 "   sc