[hibernate-dev] Interface for mapping classes : Programmatic API

Emmanuel Bernard emmanuel at hibernate.org
Tue Dec 15 04:06:37 EST 2009


AS we discussed initially, I do think it's the best approach to prevent future mistakes in the API extension.
While interfaces will work, I don't think an abstract class scheme would work though. I tried on a similar API and it did not cut it for me at the time.

Emmanuel


On 14 déc. 2009, at 15:26, Amin Mohammed-Coleman wrote:

> Hi
> 
> It seems as though my email may have been a bit too vague. So I'll try to
> explain more or provide some more information to get some advice.
> 
> At present none of the mapping class extend any particular interface or
> extend any abstract classes so it becomes difficult to a certain extent to
> remember what methods need to be present at the entity/property level
> mapping.
> 
> I know I have forgotten to add factory methods on some of the mapping
> classes when they were required.  I was therefore thinking would it be
> worthwhile introducing some form of interface that enforces the correct
> factory methods are implemented if you are creating a property level mapping
> or an entity level mapping.  So basically something in the lines of
> 
> public interface PropertyLevelMapping  {
> 
>  public FieldMapping field();
> 
>  public CalendarBridgeMapping calendarBridge(Resolution resolution);
> 
> ....
> }
> 
> 
> public interface EntityLevelMapping {
> 
>  public FullTextFilterDefMapping fullTextFilterDef (Class<?> impl);
> 
> .....
> }
> 
> So if a mapping class applies to both entity and property level then the
> mapping class would implement both.
> 
> Again I'm not sure if this the correct approach or there is something better
> that can be used.
> 
> Hope this provides some more info and apologies for not making it more
> clear!
> 
> Cheers
> Amin
> 
> On Thu, Dec 10, 2009 at 8:12 PM, Amin Mohammed-Coleman <aminmc at gmail.com>wrote:
> 
>> Hi
>> 
>> I was wondering whether to get some thoughts about the following:
>> 
>> At present none of the mapping classes implement any interface or extend
>> any abstract classes.  So I was thinking of introducing some form of
>> interface for property level mapping so that one remembers (mostly me :)) to
>> add all the methods required at the property level and the same for the
>> entity level.  I'm not sure about this so it would be cool if I could get
>> your thoughts or start some form of discussion around it.
>> 
>> 
>> Cheers
>> 
>> Amin
>> 
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev





More information about the hibernate-dev mailing list