Hi,
I have used Hibernate and Xdoclet for a while, and I'm learning how to use their .NET counterparts. Here's a few questions on the new NHibernate.Mapping.Attributes implementation included in NHibernateContrib 0.9.1:
1. Why do we need a int position in attribute constructor? It seems that it is only used when there're more than one attribute on an element.
2. Why does HbmWriter and HbmSerializer use a lot of static methods and properties? This makes it hard to extend them or config them in Spring.
3. What's the best way to customize id column name by classes' table name: I have an id property in base class, and I would like id column's name to be "${table_name}_ID" where ${table_name} is the name of the domain class's table name. (Edit: XSLT seems to be the only way to handle this)
4. How to use Component:
-- I have a value type ChangeRecord which will be used in multiple entities
-- In order to organize the entities, I used a base class BaseEntity, which has a property of type ChangeRecord:
Code:
public class BaseEntity
{
private ChangeRecord _record;
public ChangeRecord ChangeRecord
{
get{ return _record; } set { _record = value; }
}
}
[Class]
public class Entity1 : BaseEntity
{
...
}
-- Note BaseEntity is not marked by Class attribute, since it's the base class; Entity1 is marked as Class.
-- Now the question is how to use Component attribute on this setup? I searched the forum, but it seems that the suggested solution is to create a subclass of ChangeRecord for each entity class marked by Class attribute (for example, Entity1). This clearly is not an optimal solution, since the whole point of pulling ChangeRecord property up to BaseEntity is to avoid putting it in subclasses.
-- HbmWriter seems to only allow component class as a nested class inside the parent class, this restriction is annoying especially considering the point of using a component is for reuse.
Thanks
Jim