-->
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.  [ 3 posts ] 
Author Message
 Post subject: Getter and Setters do not use implicit cast operators
PostPosted: Fri Jan 27, 2006 10:00 am 
Beginner
Beginner

Joined: Tue May 17, 2005 7:25 pm
Posts: 43
Location: Somewhere, USA
Has anyone else tried to use a property who's type isn't the same as the database field type AND the custom type has an implicit cast operator overload for the database type?

For example, I have a table with an integer field. I also have a class with a "Permissions" field of type Permission class. The permission class has implicit overloads of:

public static implicit operator int(Permission p) {...}
public static implicit operator Permission(int i) {...}

The problem is that the property getter/setters are not using these operators. It only checks for IsAssignableFrom(), then bails out. Why not try direct assignment (IsAssignableFrom), then try cast overloads, IConvertible and TypeConverters in order to try all the ways of getting the data to/from the database?

Smudges


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 10:49 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Because if NH was to try it for every property of every object, it would be quite slow... This particular case could be worked around by creating a user type.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 12:32 pm 
Beginner
Beginner

Joined: Tue May 17, 2005 7:25 pm
Posts: 43
Location: Somewhere, USA
If NH were to leverage the new DynamicMethod capability in .nET 2.0, you wouldn't have any cost accept during the building of the dynamic method.

Leave the reflection for use in creating the dynamic method. That way, it's a one time only cost.

Sumdges


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.