-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: New NHibernate.Mapping.Attributes implementation
PostPosted: Tue Jun 07, 2005 6:23 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Hello,

As I was starting to implement LokateIt, I quickly found the NHM.Attributes missing some feats I need; so I first tought about implementing them, but I finally decide to do a new (non-backward compatible) implementation. :oops:

I know that it looks like a waste of time; but I end up with a "Generator" that can generate ALL the attributes with ALL the code to extract them from the Type and write them as XML. The implementation is based on some smart ideas from the current NHM.Attributes (like the [XmlEnum] for enumerations :) )

So this means a (almost) 100% coverage. :P

Almost because I still have minors problems to solve: :?

:arrow: John, how are you solving the issue of <subclass> ? (I am using the same FindAttributedProperties(), so my implementation will probably have this issue)
And is there any other know issue ? :wink:

:arrow: Add AllowMultiple for "Generator" ? (like in current NHM.Attributes.GeneratorParameterAttribute)

:arrow: AttributeUsage - Use "Class" and "Property"
Note : Use "AttributeUsage.Class" for
"Class", "Subclass", "JoinedSubclass",
"HibernateMapping", "Component" and "Discriminator"
ALL others are tagged with "AttributeUsage.Property"
Is there any problem with allowing "Field" ? (I saw a request for it...)

:arrow: <joined-subclass><key> is tagged with "AttributeUsage.Class" in current NHM.Attributes;
but it is not possible here. Problem ?

:arrow: Are "struct" allowed ? (eg. for <component>)

:arrow: How-To: Mapping of <query> and <sql-query> (of <hibernate-mapping>) ?


---

"big" problem : (if <column> matters for you :) )
When an <element> contains many <sub-elements> which can contain the same <sub-sub-element>...
Eg. <list> contains <key>, <index> and <element> which can contain <column>

If a [SubSubElement] is used, then there is no way to know to which <sub-element> it belongs
Eg.
[Attributes.List]
[Attributes.Key]
[Attributes.Column(...)]
[Attributes.Index]
[Attributes.Element]
public IList MyList { ... }

ATM, the [Column] will be used by all <sub-elements> (repetition) :(

A solution would be to make it ordered :
=> The [SubSubElement] belongs to the <sub-element> that is just before
Eg. in this case, [Column] is for [Key]
But it means that the user will have to order the <sub-elements> and it can be very painful


( this problem is only for such "concurrency" situations;
it should be possible to detect when it exist and force the ordering )

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 11, 2005 3:34 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
The "big" problem is now fixed :) The attributes are now ordered with a position index (optionnal)

Others questions are still open...

I will commit it tomorrow (hopefully :wink: )

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 12:52 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Hello,

I read the answer of John and as this new implementation should totally replace the current, I will wait that you test it and then I will remove the current NHMA and commit the new NHMA in the NHMA directory (instead of creating another directory that will be "renamed" after)

Here is the binary: NHibernate.Mapping.Attributes.Experimental-bin.zip
Here is the source code: NHibernate.Mapping.Attributes.Experimental-src.zip
Unzip it in "\NHibernateContrib\src\" and open "readme.htm".

Can you test it (by porting your projects that used NHMA) and give me some feedbacks ?
(John, you certainly have a project for that ;) )

The <subclass> issue should be solved (in FindAttributedMembers(), I break when the base class is decorated)

There is some breaking changes like
<Class><discriminator> and <JoinedSubclass><Key> was specified at class-level, but now it must be define on a (any) member of the class.
It should be possible to change that (making it class-level) but I am not sure that it will not have some nasty side effect :D
Do you want this change?

If there is some features that can not be ported, let me know. :arrow:

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Last edited by KPixel on Sat Jun 25, 2005 11:08 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 18, 2005 10:35 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
There was a little "copy'n'paste" error in the precedent release (in HbmWriterHelper.cs) that affect the (automatic) Name of <subclass> and <joined-subclass>.

It is now fixed; so you can download it again.

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 25, 2005 11:09 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
A new release is available:

Here is the binary: NHibernate.Mapping.Attributes.Experimental-bin.zip
Here is the source code: NHibernate.Mapping.Attributes.Experimental-src.zip
Unzip it in "\NHibernateContrib\src\" and open "readme.htm".

I am not planning any new release (the next will be in NHibernateContrib 0.9) :wink:

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Last edited by KPixel on Fri Jul 01, 2005 1:09 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 12:54 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Updated !
This zips reflect what will be committed in the CVS.

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject: Message received...
PostPosted: Sat Jul 02, 2005 11:28 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Here is a message I received in my mail-box:

Matthew Mastracci wrote:
I like the new NHibernate mapping implementation - it's way more
comprehensive than the previous implementation. I love how the
attributes are generated from the .xsd, rather than maintained by hand.

I have a suggestion that might make maintenance easier: you could add
custom xml attributes to the nhibernate xsd file that describe how the
element can be converted to an attribute. You can get at these extra
attributes on each schema element node with the UnhandledAttributes
property of XmlSchemaElement.

This would be useful for your Util.IsSystemType, Util.IsRoot and
Util.IsSystemType methods.


I've found a couple of elements that should be added as class/property
or assembly attributes as well:

jcs-cache: should be class, property or field, since it can apply at the
class or property level
meta: should be assembly, class, property or field, since it can apply
at the class or property level
import: should be assembly level
query/sql-query: should be assembly level
idbag: should be class level

Matt.

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Last edited by KPixel on Sat Jul 02, 2005 12:40 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 02, 2005 12:22 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Matthew Mastracci wrote:
I have a suggestion that might make maintenance easier: you could add custom xml attributes to the nhibernate xsd file that describe how the element can be converted to an attribute. [...]

It could make the maintenance of NHMA easier, but it will give more work to NHibernate developers :D As the mapping schema evolve very slowly, I don't think that it is worth.

Matthew Mastracci wrote:
I've found a couple of elements that should be added as class/property or assembly attributes as well:

jcs-cache: should be class, property or field, since it can apply at the
class or property level
meta: should be assembly, class, property or field, since it can apply
at the class or property level
import: should be assembly level
query/sql-query: should be assembly level
idbag: should be class level


For <meta> and <jcs-cache>, they can't be class-level because of the way the writers work... (same for <discriminator>)
You can put them on any property of the class (like the identifier)

<import>, <query>, <sql-query> are not supported; IIRC, it is possible to write them in a separated mapping file... (like MyImports.hbm.xml) :?
I will think about this problem and see if I can find a solution.

<idbag> is a kind of collection... I don't understand why you put it here. (a typo ? :D)


Thanks for your feedback :)
Can you tell me if it works as expected? (is there any (minor) problem/side-effect?)

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.