-->
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.  [ 1 post ] 
Author Message
 Post subject: Flush problem
PostPosted: Tue Apr 06, 2010 1:50 pm 
Newbie

Joined: Tue Apr 06, 2010 1:09 pm
Posts: 9
Greetings, I´m using .net 2.0 in a web project with c#, SQL2008 and nhibernate 2.1. I have an entity User in two pieces: User and UserParameters. Developing the maintenance module i found a mistake because when I make a flush in database the data doesn't write in database, but in the object it makes right. There is my code:

Conexion ManejadorConexion = new Conexion();
_ws = ManejadorConexion.Conectar(_ws);

_ws.Initiate();
_ws.BeginTransaction();

ClientMembershipUser RefUsu = ClientMembershipService.GetUser(Session["NUsu"].ToString());

try
{
//Either are useless, for object reference and in the same object
//User value = RefUsu.User;

//value.Active = chkActivo.Checked;
//value.Deleted = chkEliminado.Checked;

RefUsu.User.Active = chkActivo.Checked;
RefUsu.User.Deleted = chkEliminado.Checked;

_ws.PersistAll();
_ws.CommitTransaction();
}
catch
{
_ws.RollBackTransaction();
}
finally
{
_ws.Terminate();
}

The try-catch routine runs perfectly with no-error, and PersistAll() makes the flush... well, the code in that case. I have working with this model in all my project and never have seen that error, is the first time. There's no error, just doesn't make the flush and commit.

The User mapping

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="plugger.Infrastructure.Membership" assembly="plugger.Infrastructure.Membership">
<class name="User" table="sys_user" > <!--where="Deleted=0"-->
<id name="Key" type="Int64" unsaved-value="0">
<column name="IDUser" sql-type="bigint" not-null="true"/>
<generator class="hilo">
<param name="table">hi_value</param>
<param name="column">next_value</param>
<param name="max_lo">1</param>
</generator>
</id>
<property name="UserKey">
<column name="uid" length="50" sql-type="varchar" not-null="true"/>
</property>
<property name="Name">
<column name="Name" length="50" sql-type="varchar" not-null="true"/>
</property>
<property name="UserName">
<column name="Username" length="30" sql-type="varchar" not-null="true"/>
</property>
<property name="Email">
<column name="Email" length="50" sql-type="varchar" not-null="false"/>
</property>
<property name="CreationDate">
<column name="FechaCreacion" sql-type="datetime" not-null="true"/>
</property>
<property name="PasswordQuestion">
<column name="PasswordPregunta" length="100" sql-type="varchar" not-null="false"/>
</property>
<list name="Groups" table ="sys_user_group" lazy="true" cascade="all">
<key column="IDUser" />
<index column="Orden" />
<many-to-many column="IDGroup" class="Group"/>
</list>
<property name="IsLockedOut">
<column name="IsLockedOut" sql-type="smallint" not-null="true"/>
</property>
<property name="LastActivityDate">
<column name="LastActivityDate" sql-type="datetime" not-null="true"/>
</property>
<property name="LastLockoutDate">
<column name="LastLockoutDate" sql-type="datetime" not-null="true"/>
</property>
<property name="LastLoginDate">
<column name="LastLoginDate" sql-type="datetime" not-null="true"/>
</property>
<property name="LastPasswordChangedDate">
<column name="LastPasswordChangedDate" sql-type="datetime" not-null="true"/>
</property>
<property name="PasswordSalt">
<column name="PasswordSalt" length="50" sql-type="varchar" not-null="true"/>
</property>
<property name="PasswordFormat">
<column name="PasswordFormat" sql-type="smallint" not-null="true"/>
</property>
<property name="FailedPasswordAttemptCount">
<column name="FailedPasswordAttemptCount" sql-type="int" not-null="true"/>
</property>
<property name="FailedPasswordAttemptWindowStart">
<column name="FailedPasswordAttemptWindowStart" sql-type="datetime" not-null="true"/>
</property>
<property name="FailedPasswordAnswerAttemptCount">
<column name="FailedPasswordAnswerAttemptCount" sql-type="int" not-null="true"/>
</property>
<property name="FailedPasswordAnswerAttemptWindowStart">
<column name="FailedPasswordAnswerAttemptWindowStart" sql-type="datetime" not-null="true"/>
</property>
<property name="Active">
<column name="Active" sql-type="smallint" not-null="true"/>
</property>
<property name="Deleted">
<column name="Deleted" sql-type="smallint" not-null="true"/>
</property>
</class>
</hibernate-mapping>

The UserParameters mapping

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="plugger.Infrastructure.Membership" assembly="plugger.Infrastructure.Membership">
<class name="UserParameters" table="sys_user" > <!--where="Deleted=0"-->
<id name="Key" type="Int64" unsaved-value="0">
<column name="IDUser" sql-type="bigint" not-null="true"/>
<generator class="hilo">
<param name="table">hi_value</param>
<param name="column">next_value</param>
<param name="max_lo">1</param>
</generator>
</id>
<property name="UserName">
<column name="Username" length="30" sql-type="varchar" not-null="true"/>
</property>
<property name="PasswordQuestion">
<column name="PasswordPregunta" length="100" sql-type="varchar" not-null="false"/>
</property>
<property name="PasswordAnswer">
<column name="PasswordRespuesta" length="100" sql-type="varchar" not-null="false"/>
</property>
<property name="UserHash">
<column name="UserHash" length="32" sql-type="varchar" not-null="false"/>
</property>
<property name="LastPasswordChangedDate">
<column name="LastPasswordChangedDate" sql-type="datetime" not-null="true"/>
</property>
<property name="PasswordSalt">
<column name="PasswordSalt" length="50" sql-type="varchar" not-null="true"/>
</property>
<property name="PasswordFormat">
<column name="PasswordFormat" sql-type="smallint" not-null="true"/>
</property>
<property name="Password">
<column name="Password" length="32" sql-type="varchar" not-null="false"/>
</property>
</class>
</hibernate-mapping>

Any suggestion?
Thanks a lot
Xavier


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

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.