If I were the captain on a big steamboat...
We've moved
New blog found here at http://blogs.chayachronicles.com/sonofnun/Default.aspx
RSS is here at http://blogs.chayachronicles.com/sonofnun/Rss.aspx
Thanks to GWB for parking me here for a spell :)
MIKE
I've been working exclusively alone on a project for a while and have as much liberty as any developer could hope for. I'm a blessed man. Nonetheless, I have tried to kind of "pretend" like I am working in a team environment that has regimented deadlines. This is mostly due to integrity and partly due to prevention for laziness...how easy is it to constantly be researching solutions without implementing them? There was a necessary period of growth in skill sets that had to occur and while I certainly ......
I am sure everyone else has already figured this out but thought I'd jot it down here. I wanted to isolate all messages being sent from NHibernate to its own logging file. NHibernate has lots to say during its operations and often the messages it delivers are the only way of tracking down some obsure error since sometimes the exception messages in NHibernate are...well, wanting. After poking around the forums and trying out a few methods, here is how I finally split my NHibernate logs from the rest ......
I needed to implement a component that uses generic parameters. Documentation is sketchy on NHibernate so thot I'd jot it here. I *stole* an IRange implementation from someone and needed to use it for a date range within a class. <component name="DateTimeRange" class="Cei.eMerge.Common.Ra... Cei.eMerge.Common" access="field.camelcase-und... > <property name="Start" access="field.camelcase"> <column name="StartDate" not-null="true" /> </property> <property ......
I am sure I everyone else knows this by now, but I wanted to jot a note. When you are passing strings to an HQL query, it's best practice to assign those strings to a parameter (named or positional) and let HQL escape the special characters for you. So it would look like this when searching by a Name and Distinction tag on an Entity: StringBuilder queryString = new StringBuilder(); queryString.Append("from Entity e where e.Name= :name AND "); queryString.Append("e.Disti... = :distinctionTag ......
While trying to tighten down access to invariants within an Aggregate, I'd like to make the exposed collections ReadOnly. Then I control the addition of child objects thru exposed methods, thus enforcing the Aggregate's role as gatekeeper for these objects. The problem is, I am mapping NHibernate to my fields which implement IList which, of course, allow .Add(T entity) and casting to an ReadOnlyCollection in the exposed property isn't going to work. So I poked around the Algorithms utility class ......
In a previous post I proposed a Generic class for building custom types using NHibernate. This lets us keep our Domain entities free from requiring hidden fields or other methods to persist Value Objects. While a Component may be used, this little Generic class lets us keep the power of HQL for our complex types. One situation that is not addressed in the Hibernate in Action book, though, is what to do when you want to combine these Value Objects into one Value Object. For example, if we have a Money ......
According to this outstanding bug here, failing to put an access strategy on a collection that doesn't have a setter result in an exception that is enigmatic at best. Thankfully, I found this and found a mapping that didn't have a default access strategy on it...that fixed it.
One of the difficult things about NHibernate is just getting started. While it is true that there is lots of docs and writings about her older brother Hibernate, the fact is that the documentation for NHibernate is really bad. It is true that it is just a port of Hibernate, so you can get thru it just studying the Hibernate docs. The big one to have is Hibernate in Action. On occasion, I would get errors when trying to persist a collection that perhaps bidirectionality (is that a word?) that would ......
When trying to map a custom type using NHibernate, you have to decide whether to implement IUserType or ICompositeUserType. IUserType is slightly simpler to implement but doesn't support using HQL for the custom types underlying properties. To use the power of HQL, you'll need to implement ICompositeUserType. I have an generic example here. Using this interface you can use the underlying properties within your custom type in the HQL ... very cool. The greates benefit of using these interfaces in ......
Full O/R Mappers Archive