Hi I need to have synchronziation in my application between a central
server and a clients local server, luckily for me its one-way from
server to client. The transport will I solve with WCF. But now Im
wondering how I'm gonna track changes, the solution In thinking about
right now is with this mapping: (Simple example).

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                  assembly="NHibernateVersioningTest"
                  namespace="NHibernateVersioningTest"
                  default-lazy="false">
  <class name="ISynchronizable" table="SynchronizableItems">
    <id name="Id" type="System.Guid">
      <generator class="assigned" />
    </id>

    <property name="Version" type="System.Int64" not-null="true" />
    <joined-subclass name="Employee">
      <key column="Id"/>
      <property name="Name" type="string" not-null="true" />
    </joined-subclass>

    <joined-subclass name="Article">
      <key column="Id"/>
      <property name="Name" type="string" not-null="true" />
      <property name="UnitPrice" type="decimal" not-null="true" />
    </joined-subclass>

    <joined-subclass name="Organization">
      <key column="Id"/>
      <property name="Name" type="string" not-null="true" />
    </joined-subclass>
  </class>
</hibernate-mapping>

With this example I need to do an select before I save something for
example when saving an article.

var currentVersion = .CreateCriteria<ISynchronizable>().AddOrder
(Order.Desc("Version")).SetMaxResults(1).UniqueResult
                        <ISynchronizable>().Version;

article.Version = currentVersion+1;
session.Save(article);

And when the client wan'ts all new updates it can send the server the
latest versionnumber to receive all new objects at once.
public IEnumerable<ISynchronizable> GetUpdates(long fromVersionNumber)
{
return (from item in sessionProvider.Session.Linq<ISynchronizable>()
where item.Version > 60 select item).ToList()
}

At the client side he checks with an select looking for the id, if the
object is just a new version then it uses session.Merge, or if its a
new one session.Save.

I wonder if it is alot of flaws in this solution, and maybe someone
who already has done something similar, I just dont feel right with
this solution.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to