XEdwin / jcouchdb

Automatically exported from code.google.com/p/jcouchdb
Other
0 stars 0 forks source link

Improvement: Customizable DocumentHelper #43

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
My Possibilities on changing the code of the domain-objects which i want to
store in the couchdb are very limited. I would like to be able to change
the documenthelper because this one needs to change the Source of the
Domain objects, e.g. (inside getRevision(Object document)):

if (document instanceof Document) // Need to implement an interface
{
      return ((Document) document).getRevision();
}
String name = getPropertyNameFromAnnotation(document, "_rev");
return (String) PropertyUtils.getProperty(document, name);

In both cases a change of the Sourcecode is needed.

So a suggestion to workaround that limitation would be to create a
interface for the documenthelper (change the methods to non-static) and a
possibility to inject a DocumentHelper to the Database-Class. You can do
this as a lazy-getter which is instantiating the Default-one and you have
no changes in the interface of jcouchdb (no need to set a Documenthelper if
you are happy with the Default-implementation).

Original issue reported on code.google.com by kneunert@gmail.com on 28 Mar 2010 at 9:39

GoogleCodeExporter commented 9 years ago
If you can't change the the domain objects, where will you store the revision?

Wouldn't it be easier to use document wrapper for jcouchdb?

Original comment by ff...@gmx.de on 28 Mar 2010 at 1:51

GoogleCodeExporter commented 9 years ago
a feq additional words to the use case: I'm using a codegenerator which i'm not 
able
to change. So, i can add a revision-attribute with getters and setters but i'm 
not
able to annotate or let the objects implement interfaces. Document wrappers 
would be
a possibility, but in fact, that would be the same than wrapping the 
codegenerator
and generating another artifact which is wrapping the original one, and i would 
like
to avoid that ...

Original comment by kneunert@gmail.com on 28 Mar 2010 at 1:59

GoogleCodeExporter commented 9 years ago
And unfortunately, i'm also not able to generate properties with a leading 
underscore
like "_rev".

Original comment by kneunert@gmail.com on 28 Mar 2010 at 4:54

GoogleCodeExporter commented 9 years ago
refactored DocumentHelper to implement new interface
org.jcouchdb.document.DocumentPropertyHandler. r252

Original comment by ff...@gmx.de on 31 Mar 2010 at 8:35

GoogleCodeExporter commented 9 years ago
Thanks a lot, i know that you have plenty of stuff to do right now :-)

Original comment by kneunert@gmail.com on 1 Apr 2010 at 5:29