当前位置: 代码迷 >> Java Web开发 >> hibernate+spring 插入数据
  详细解决方案

hibernate+spring 插入数据

热度:29   发布时间:2016-04-17 01:20:24.0
hibernate+spring 插入数据 高手请进
有一个用户表映射如下,其中头像和权限引用外键,同时本表用户的code又被其它表引用
我要怎么才能插入数据 ,望高手指教


XML code
<hibernate-mapping>    <class name="com.mwgj.wmw.spring.Wmwusertable" table="wmwusertable" lazy="false">        <id name="wmwUid" type="java.lang.Integer">            <column name="wmw_uid" />            <generator class="native"></generator>        </id>        <many-to-one name="wmwheadimgtable" class="com.mwgj.wmw.spring.Wmwheadimgtable" fetch="select">            <column name="wmw_uheadportrait">                <comment>头像</comment>            </column>        </many-to-one>        <many-to-one name="wmwpopedomtable" class="com.mwgj.wmw.spring.Wmwpopedomtable" fetch="select">            <column name="wmw_upopedom" not-null="true">                <comment>权限</comment>            </column>        </many-to-one>        <property name="wmwUcode" type="java.lang.String">            <column name="wmw_ucode" not-null="true" unique="true">                <comment>用户code</comment>            </column>        </property>        <property name="wmwUuser" type="java.lang.String">            <column name="wmw_uuser" length="20" not-null="true">                <comment>用户名</comment>            </column>        </property>        <property name="wmwUpass" type="java.lang.String">            <column name="wmw_upass" length="30" not-null="true">                <comment>密码</comment>            </column>        </property>        <property name="wmwUnickname" type="java.lang.String">            <column name="wmw_unickname" length="20" not-null="true" unique="true">                <comment>昵称</comment>            </column>        </property>        <property name="wmwUwisdom" type="java.lang.String">            <column name="wmw_uwisdom" length="176">                <comment>名言</comment>            </column>        </property>        <property name="wmwUmail" type="java.lang.String">            <column name="wmw_umail" length="40" not-null="true" unique="true">                <comment>邮箱</comment>            </column>        </property>        <property name="wmwUuserinfo" type="java.lang.String">            <column name="wmw_uuserinfo">                <comment>用户信息</comment>            </column>        </property>        <property name="wmwUinitpass" type="java.lang.String">            <column name="wmw_uinitpass" length="30" not-null="true">                <comment>初始密码</comment>            </column>        </property>        <property name="wmwUregdate" type="java.util.Date">            <column name="wmw_uregdate" length="0">                <comment>注册时间</comment>            </column>        </property>        <property name="wmwUlogdate" type="java.util.Date">            <column name="wmw_ulogdate" length="0">                <comment>最后登陆时间</comment>            </column>        </property>        <property name="wmwUlogtime" type="java.util.Date">            <column name="wmw_ulogtime" length="0">                <comment>在线时长</comment>            </column>        </property>        <set name="wmwpassprotecttables" inverse="true">            <key>                <column name="wmw_ppcode" not-null="true">                    <comment>用户code</comment>                </column>            </key>            <one-to-many class="com.mwgj.wmw.spring.Wmwpassprotecttable" />        </set>    </class></hibernate-mapping>
  相关解决方案