I just have an opportunity to use Borland Together 2005 for VS.NET. Its LiveSource ? feature is very cool !!!. So, I’m here to tell my experience.
I’m evaluating a modeling tool for modeling business sytem that will be implemented using NHibernate. This system will contains 70-80 classes (a small-medium system). Someone who visited my website may be wonder why I don’t use ECO III. The main reason is because ECO III doesn’t work will with MySQL dbms. The other reason is that ECO III uses the unified approach to maintain object id, so the system may have a number of objects no more that 2^31 (please correct me if I’m wrong). However, this limitation is not a problem for a small to medium system. I calculated that the system can run and work well for at least 50 years. But the problem will occur when there are a lot of transaction per day. Object ids will be run out, and ECO won’t reuse any deleted id.
On the other hand, NHibernate is boring because it cannot fully manage bi-directional associations because it isn’t controlled by a state machine, which ECO has. The main advantages of NHibernate are. 1. ) It allows developer to do o/r mapping at low-level, and 2.) NHibernate objects are plain .NET objects (while ECO objects are not, all ECO business entity implements IObject interface).
I’m evaluating DevExpress XtraGrid for UI layer, it’s amazing control. Not much needed to say. Its databinding ability is extremely cool !!. One problem I encountered for NHibernate with DevExpress and other GUI layer is just we need to implement Equals, ToString, Hash methods for every class. And I’m now ready to by XtraGrid :). FYI, I use ObjectViews to connect NHibernate to XtraGrid instead of ISet, IList or Array.
Back to Together, it is useful for modeling and it makes me wonder that why Together for VS.NET is faster that Together for Delphi (they should be share the same implementation, shouldn’t they.) Code synchronization is beautiful (v. SP1) I am much faster to model the business entity. AFAIK, Together is one of a few tools that allow designer to put some attributes to the design elements (class, method). I think Rational XDE also have this feature, but didn’t try yet. One feature I don’t see in Together is automatic field encapsulation as property, which is needed by NHibernate. May be I just don’t know how to use it (please tell me if you know). Other great features of Together are namespace management, and enum and inner class modeling, which may be useful for one who uses NHibernate. Together also provides very flexible refactoring.
Wednesday, March 15, 2006
Together + NHibernate ~= A Great Duo
Posted by
chanwit
at
1:41 AM
2
comments
Labels: .NET, NHibernate
Wednesday, January 18, 2006
Moved to Manchester
Long time no posting.
I'm very busy about moving from Thailand to Manchester, UK.
This is the first day in Manchester that I can online more than 3 hrs :).
I'll study a PhD research program at the University of Manchester for, at least, 3 years.
Posted by
chanwit
at
12:37 PM
1 comments
Thursday, October 13, 2005
Sequence = Firebird Generator in NHibernate 1.0
Code below shows how to use "sequence" to have an auto-incremental field in NHibernate 1.0 with Firebird.
I use Generator(Class="sequence") to make a field to be autoinc, and if you want to specify a generator name, you can use a Param(Name="sequence", Content) attribute.
namespace TestNHibernate
{
[Serializable]
[Class(NameType=typeof(TestClass))]
public class TestClass {
private int _id;
private string _name;
public TestClass() {
}
[Id(1, Name="Id")]
[Generator(2, Class="sequence")]
[Param(3, Name="sequence", Content="TestClass_Id_Gen")]
public int Id {
get{ return _id;}
set{ _id = value; }
}
[Property(Name="Name", Length=10)]
public string Name {
get { return _name; }
set { _name = value; }
}
}
}
Posted by
chanwit
at
5:12 PM
2
comments
Labels: .NET, NHibernate
NHibernate 1.0 and Firebird
I've some experiences with Hibernate 2.1 but never touch NHibernate.
It's first time I play around NHibernate, just because I want to test it.
I found that NHibernate meets my all criterias (create DDL, gen mapping on the fly, etc.) to enable MDA.
I use mapping attributes from NHibernateContrib to model a domain class (see below).
// new configuration
Configuration config = new Configuration();
// set properties
IDictionary props = new Hashtable();
props["hibernate.connection.provider"] =
"NHibernate.Connection.DriverConnectionProvider";
props["hibernate.dialect" ] =
"NHibernate.Dialect.FirebirdDialect";
props["hibernate.connection.driver_class"] =
"NHibernate.Driver.FirebirdDriver" ;
props["hibernate.connection.connection_string"] =
"User=SYSDBA;Password=masterkey;" +
"Database=C:\\workspace\\FirebirdNET\\test.fdb;" +
"DataSource=;Port=3050;Dialect=3;Charset=NONE;Role=;" +
"Connection lifetime=0;Connection timeout=15;" +
"Pooling=True;Packet Size=8192;Server Type=0";
config.AddProperties(props);
// auto-generate Hbm on-the-fly
using( MemoryStream stream = new MemoryStream() ) {
HbmSerializer.Default.Serialize(stream, typeof(TestClass));
stream.Position = 0;
config.AddInputStream(stream);
}
// create database schema
SchemaExport s = new SchemaExport(config);
s.Create(true, true);
sf = config.BuildSessionFactory();
// create an object, then save
using(ISession ss = sf.OpenSession()) {
ITransaction tx = ss.BeginTransaction();
TestClass tc = new TestClass();
tc.Id = 1;
ss.Save(tc);
tx.Commit();
ss.Close();
}
// try find the object as IList
using(ISession ss = sf.OpenSession()) {
IList a = ss.Find("from TestClass");
Text = a.Count.ToString();
ss.Close();
}
A sample domain class:
using System;
using NHibernate.Mapping.Attributes;
namespace TestNHibernate {
[Serializable]
[Class(NameType=typeof(TestClass))]
public class TestClass {
public TestClass() {
}
private int id;
[Id(-2, Name="Id")]
[Generator(-1, Class="assigned")]
public int Id {
get{ return id;}
set{ id = value; }
}
}
}
Posted by
chanwit
at
2:15 AM
1 comments
Labels: .NET, NHibernate