-->
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.  [ 1 post ] 
Author Message
 Post subject: Repositories and the decorator pattern.
PostPosted: Thu Dec 06, 2007 6:06 am 
Newbie

Joined: Fri Jan 05, 2007 5:36 am
Posts: 16
Hi,

I have some question regarding my approach of using decorator pattern with my repositories.

Here is how my IRepository<T> looks:

void Save(T entity);
void Delete(T entity);
T Load(object id);
IList<T> Find();
IList<T> Find(ICriteria criteria);
IList<T> Find(IQuery query);
IList<T> Find(ISQLQuery query);

Well, now I may want to use an ADO.NET repository instead of an NHibernate repository.
What should I do with the ICriteria, IQuery and ISQLQuery?
It's not like I will need them for my ADO.NET repository.
I need to implement them to use my repository decorators.

The second problem is when I want to create my, let's say, "CustomerRepository". Would I gain anything from trying to implement IRepository<T>?
I want to use custom methods like: GetCustomerById(int id) instead of using Load(ICriteria criteria) right but then I would not be able to work against IRepository<T>.

I'm using MVP in this application (I'm new to it) and I really don't want to provide my IRepository<Customer> with an NHibernate criteria in my presenter right?

Sorry for my bad english and I hope you understood what I meant.

Summary:

1. Is there any good way of getting an generic interface for my Repositories so I can change from NHibernate to ADO.NET for my repository without to much changes?

2. Is it a good idea to not implement IRepository<Customer> for an CustomerRepository and make custom methods or where should I place my custom queries? In my presenters?

Thanks!


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

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.