«网站首页
  • 回复:4 浏览:1943 2011-01-13 11:56 来自 Hypo

    1。在插入Blacklist对象的时候报错。

     2。我尝试着删除的两端配置节(代码中灰化部分)之后添加成功,但是在查询出来的Blacklist对象中的关联的父对象都为空。

     3。以下是Blacklist映射的配置表。这个问题困扰我好久,希望有人帮我解决一下,谢谢! 

    1 <?xml version='1.0' encoding='utf-8' ?>
    2  <hibernate-mapping xmlns='urn:nhibernate-mapping-2.2'
    3 assembly='Model'
    4 namespace='Model'
    5 >
    6 <class name='Blacklist'
    7 table='`Blacklist`'
    8 >
    9 <id name='Id'
    10 column='`Id`'
    11 >
    12 <generator class='native'>
    13 </generator>
    14 </id>
    15 <property name='Number'
    16 column='`Number`'
    17 />
    18 <property name='SearchCount'
    19 column='`SearchCount`'
    20 />
    21 <property name='ReportCount'
    22 column='`ReportCount`'
    23 />
    24 <property name='AccusedCityId'
    25 column='`AccusedCityId`'
    26 />
    27 <property name='AssuedIp'
    28 column='`AssuedIp`'
    29 />
    30 <property name='AssuedName'
    31 column='`AssuedName`'
    32 />
    33 <property name='UserId'
    34 column='`UserId`'
    35 />
    36 <property name='ReportTime'
    37 column='ReportTime'
    38 />
    39 <bag name='BlacklistRelationFastGroups' cascade='all' inverse='false'>
    40 <key column='`BlacklistId`' />
    41 <one-to-many class='BlacklistRelationFastGroup' />
    42 </bag>
    43
    44 <bag name='BlacklistRelationFeatures' cascade='all' inverse='false'>
    45 <key column='`BlacklistId`' />
    46 <one-to-many class='BlacklistRelationFeature' />
    47 </bag>
    48
    49 <bag name='Indicatives' cascade='all' inverse='false'>
    50 <key column='`BlackId`' />
    51 <one-to-many class='Indicative'/>
    52
    53 </bag>
    54 <many-to-one name='User' class='Users' column='`UserId`' />
    55 <many-to-one name='AccusedCity' class='Region' column='`AccusedCityId`'/>
    56 </class>
    57 </hibernate-mapping>

     

  • 李永京
    2011-01-13 13:33 李永京
    Mapping配置关联主键错误...
    回复 第1楼 回到顶楼
  • Ixixi2010
    2011-01-13 14:40 Ixixi2010
    @李永京
    谢谢,虽然已经得到了解决,的确是配置文件的错误。
    reference:
    http://codeverity.com/timweaver/nhibernate-invalid-index-for-this-sqlparametercollection/
    回复 第2楼 回到顶楼
  • Sum_yang
    2011-04-16 17:23 Sum_yang
    我也碰到了类似问题,能否帮忙解决下
    <?xml version="1.0" encoding="utf-8" ?>
    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Web.Creater.Domain" namespace="Web.Creater.Domain">
    <class name="Article" table="tb_Article" lazy="true" >
    <id name="ArticleId" column="ArticleId" type="string" >
    <generator class="assigned" />
    </id>
    <property name="ArtilceTitle" type="string">
    <column name="ArtilceTitle" length="5"/>
    </property>

    <property name="AritlceShortTitle" type="string">
    <column name="AritlceShortTitle" length="5"/>
    </property>

    <property name="ArticleTag" type="string">
    <column name="ArticleTag" length="50"/>
    </property>

    <property name="ShortImg" type="string">
    <column name="ShortImg" length="50"/>
    </property>

    <property name="ArticleFrom" type="string">
    <column name="ArticleFrom" length="50"/>
    </property>

    <property name="ArticleAuthor" type="string">
    <column name="ArticleAuthor" length="50"/>
    </property>

    <property name="ArticleCate" type="string">
    <column name="ArticleCate" length="50"/>
    </property>

    <property name="KeyWords" type="string">
    <column name="KeyWords" length="50"/>
    </property>

    <property name="ArticleSummary" type="string">
    <column name="ArticleSummary" length="150"/>
    </property>

    <property name="ArticleContents" type="string">
    <column name="ArticleContents" length="2000"/>
    </property>

    <property name="CanDiscuss" type="string">
    <column name="CanDiscuss" length="50"/>
    </property>

    <property name="hits" type="Int32">
    <column name="hits" />
    </property>

    <property name="ArticleOrder" type="Int32">
    <column name="ArticleOrder" />
    </property>

    <property name="AritcleTitleColor" type="string">
    <column name="AritcleTitleColor" length="50"/>
    </property>

    <property name="ArticleExamine" type="string">
    <column name="ArticleExamine" length="50"/>
    </property>

    <property name="ArticlePulbicDate" type="DateTime">
    <column name="ArticlePulbicDate" length="50"/>
    </property>

    <property name="PublicPerson" type="string">
    <column name="PublicPerson" length="50"/>
    </property>

    <many-to-one name="ColumnM" lazy="false" column="ArticleCate"/>
    </class>
    </hibernate-mapping>
    回复 第3楼 回到顶楼
  • 大肥猫
    2011-08-15 17:01 大肥猫
    没有用,insert="false" update="false"
    这样的话,被标识的对象就无法更新了。
    回复 第4楼 回到顶楼
登录用户才能评论,请先登录注册


Top