-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: muliEntity in gridview not update it's value. cache?
PostPosted: Wed Jun 27, 2007 1:50 am 
Newbie

Joined: Tue Jun 26, 2007 10:04 pm
Posts: 4
Hibernate version:NHIbernate 1.2

Mapping documents:NHibernate.mapping.attributes

Generate mapping document:
Code:
  <class name="KingonSoft.House.Entity.Role, KingonSoft.House.Entity" table="up_role">
    <id name="Id" column="id" type="long">
      <generator class="native" />
    </id>
    <property name="RoleTypeId" type="long" column="role_type_id" />
    <property name="Name" type="String" column="name" length="20" />
    <property name="Description" type="String" column="description" length="255" />
    <many-to-one name="RoleType" class="KingonSoft.House.Entity.RoleType, KingonSoft.House.Entity" column="role_type_id" update="false" insert="false" />
    <set name="Users" table="up_user_role">
      <key column="role_id" />
      <many-to-many class="KingonSoft.House.Entity.User, KingonSoft.House.Entity" column="user_id" />
    </set>
    <set name="Permissions" table="up_role_permission">
      <key column="role_id" />
      <many-to-many class="KingonSoft.House.Entity.Permission, KingonSoft.House.Entity" column="permissin_id" />
    </set>
  </class>


  <class name="KingonSoft.House.Entity.RoleType, KingonSoft.House.Entity" table="up_role_type">
    <id name="Id" column="id" type="long">
      <generator class="native" />
    </id>
    <property name="Name" type="String" column="name" length="50" />
    <property name="Description" type="String" column="description" length="255" />
    <set name="Roles" lazy="true" cascade="delete-orphan" inverse="true">
      <key column="role_type_id" />
      <one-to-many class="KingonSoft.House.Entity.Role, KingonSoft.House.Entity" />
    </set>
  </class>


When I use IList<Role> GetRoleList() it alwayls not update the RoleType until I start a new page.
Example:
there are two roletype entity:
id name
1 roleType1
2 roleType2

gridview display
id roleName roleType.Name
1 role1 roleType1
2 role2 roleType2


when i edit role1 role.roleTypeId form 1 to 2 in gridview updating event function it display like:

id roleName roleType.Name
1 role1 roleType1
2 role2 roleType2

until I start a new page or restart a new edit event;
id roleName roleType.Name
1 role1 roleType2
2 role2 roleType2



anybody can help me? thanks .
the code is below
Code:
        IList<Role> list = _roleBLL.GetRoleList();
        grvRole.DataSource = list;
        grvRole.DataKeyNames = new String[] {"Id"};
        grvRole.DataBind();

<asp:TemplateField HeaderText="角色类型" SortExpression="RoleTypeId">
                <EditItemTemplate>
                    <asp:DropDownList ID="drpRoleType" runat="server">
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblRoleType" runat="server" Text='<%# Eval("RoleType.Name") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>


When I change the roletype in dropdownlist like this:
[code]
long id = int.Parse(lblId.Text);
Role role = _roleBLL.Load(id);

role.Name = txtName.Text;
role.Description = txtDescription.Text;
role.RoleTypeId = int.Parse(drpRoleType.SelectedValue);

_roleBLL.Update(role);
grvRole.EditIndex = -1;
//grvRoleBind();
IList<Role> list = _roleBLL.GetRoleList();
grvRole.DataSource = list;
grvRole.DataKeyNames = new String[] {"Id"};
grvRole.DataBind();
[code]

its value of RoleTypeId was changed, but if you watch the value of RoleType. it doesn't change.
if you refresh your page or start a new edit upage in gridview.now the value of roletype will get a new value.

is there a cache? when you update the value then immediately in , perhapse in the same session, reget his value, the value is old.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 27, 2007 2:12 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
NHibernate doesn't do any kind of magic to bind RoleTypeId and RoleType together so that changing one changes the other. It's up to you to implement.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 27, 2007 2:27 am 
Newbie

Joined: Tue Jun 26, 2007 10:04 pm
Posts: 4
thanks for your reply.

I set it's value at same time, It work!

role.RoleTypeId = X
role.RoleType = X


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.