Change collection-type in .hbm-files?
-
- Posts: 4
- Joined: Thu 12 Jun 2014 12:12
Change collection-type in .hbm-files?
Dear Sir or Madam,
in our current project we make great use of Entity Developer in combination with .net and wpf. The problem was: How to make Iesi.Collection.ISet notifyable as for example ObservableCollection<T>. We have solved this issue using our own classes like PersistentObservableSet, ObservableHashedSetType and ObservableSet. Also we have modified the default template file (.tmpl) of Entity Developer to modify the Type of the collections in the .cs-Domain-files. In our mapping files (hbm.xml) however we defined the collection sets MANUALLY (after generating c#-code from within Entity Developer) as following: <set name="MietartikelTarifes" inverse="true" generic="true" collection-type="Obi.Persistance.Common.ObservableHashedSetType`1[[MietartikelTarife]], Obi.Persistance">. And it made our day. Perfect. But as we own Entity Developer licence it would the best to generate the collections in mapping of our Entities of type "Obi.Persistance.Common.ObservableHashedSetType`1[[MietartikelTarife]]" BY THE TOOL. How can we achieve this? Is there a solution out there? Have we overseen any buttons / checkboxes? Is there anything we can do more with template files?
Best regards
Vadim
in our current project we make great use of Entity Developer in combination with .net and wpf. The problem was: How to make Iesi.Collection.ISet notifyable as for example ObservableCollection<T>. We have solved this issue using our own classes like PersistentObservableSet, ObservableHashedSetType and ObservableSet. Also we have modified the default template file (.tmpl) of Entity Developer to modify the Type of the collections in the .cs-Domain-files. In our mapping files (hbm.xml) however we defined the collection sets MANUALLY (after generating c#-code from within Entity Developer) as following: <set name="MietartikelTarifes" inverse="true" generic="true" collection-type="Obi.Persistance.Common.ObservableHashedSetType`1[[MietartikelTarife]], Obi.Persistance">. And it made our day. Perfect. But as we own Entity Developer licence it would the best to generate the collections in mapping of our Entities of type "Obi.Persistance.Common.ObservableHashedSetType`1[[MietartikelTarife]]" BY THE TOOL. How can we achieve this? Is there a solution out there? Have we overseen any buttons / checkboxes? Is there anything we can do more with template files?
Best regards
Vadim
Re: Change collection-type in .hbm-files?
Thank you for your suggestion. We will notify you when the possibility of specifying custom collection type name for HibernateRelationProperty via interface of Entity Developer is implemented.
-
- Posts: 4
- Joined: Thu 12 Jun 2014 12:12
Re: Change collection-type in .hbm-files?
Dear Sir or Madam,
do you have plans for releasing this feature in the near future? If you do, could you say when it will be released? We really need this feature. We are about to help us only by modifying code manually and this is really annoying and time intense.
Best regards
Vadim
do you have plans for releasing this feature in the near future? If you do, could you say when it will be released? We really need this feature. We are about to help us only by modifying code manually and this is really annoying and time intense.
Best regards
Vadim
Re: Change collection-type in .hbm-files?
We will try to implement the feature before releasing the next public build (in two weeks).
-
- Posts: 4
- Joined: Thu 12 Jun 2014 12:12
Re: Change collection-type in .hbm-files?
Sounds good! Thank you!
Kind regards,
Vadim
Kind regards,
Vadim
Re: Change collection-type in .hbm-files?
The new (5.7.412) build of Entity Developer is available for download. This version allows to implement the needed functionality in the following alternative ways:
1. Via interface of Entity Developer.
Navigate to Model Settings > Model > Extended Properties > RelationProperty > press Add and set Name=CollectionTypeName, Property Type=System.String > OK.
Now select HibernateRelationProperty, and you will find Collection Type Name in the Extended Properties submenu in the Properties window. Specify the type name. As a result, collection-type="specified_type_name" will be added in the corresponding <set/> section in *.hbm.xml.
2. By modifying template via embedded T4 Editor. Add the following entry in the template:Now select HibernateRelationProperty, and you will find Collection Type Name in the Extended Properties submenu in the Properties window. Specify the type name. As a result, collection-type="specified_type_name" will be added in the corresponding <set/> section in *.hbm.xml.
1. Via interface of Entity Developer.
Navigate to Model Settings > Model > Extended Properties > RelationProperty > press Add and set Name=CollectionTypeName, Property Type=System.String > OK.
Now select HibernateRelationProperty, and you will find Collection Type Name in the Extended Properties submenu in the Properties window. Specify the type name. As a result, collection-type="specified_type_name" will be added in the corresponding <set/> section in *.hbm.xml.
2. By modifying template via embedded T4 Editor. Add the following entry in the template:
Code: Select all
<#@ extended name="CollectionTypeName" owner="RelationProperty" type="System.String" description="The assembly-qualified name of the custom collection type." #>
-
- Posts: 4
- Joined: Thu 12 Jun 2014 12:12
Re: Change collection-type in .hbm-files?
Thank you very much! This works very well for us!
Kind regards,
Vadim
Kind regards,
Vadim
Re: Change collection-type in .hbm-files?
We use a custom collection for all our bag relationships. Is there a way to specify the custom collection is generic using the Default Value of the CollectionTypeName property? I see how to do it for each individual field, but we have a large number tables, so it would be convenient if this could be automated.
Thanks.
Thanks.
Re: Change collection-type in .hbm-files?
We will investigate the question and notify you about the result.
Re: Change collection-type in .hbm-files?
We ended up modifying the GetRelationPropertyCollectionInitialization method in the NHibernate template as shown below. This accomplished our goal, but am concerned about long term effects of customization to the templates when there are product updates.
Side Note: Entity Developer has saved us a lot of time on our project. Thanks.
Code: Select all
case HibernateCollectionType.Idbag:
//Customized this to use the our custom collection
if (relationProperty.Generic)
return string.Format("Data.Lists.ObservableList<{0}>()", relationClassName);
else
return "ArrayList()";
Re: Change collection-type in .hbm-files?
The bug with applying Generic=True to the CollectionTypeName extended relation property (it is predefined now) in the NHibernate template is fixed: viewtopic.php?f=32&t=38876.