Re: Prevalent Repository
Diego Miranda <[email protected]>
| Newsgroups | gmane.comp.java.prevayler |
|---|---|
| Message-ID | <[email protected]> |
Hi Justin!
| Does each method of PrevalenceRepository send a Query or Transaction to an
underlying Prevayler instance?
Yes, each method sends a Query or Transaction. There is an unique entry
point to the repository. This is a Repository interface and has the
following methods:
@Query public Object getImmutableByOId (Integer id);
@Query public int size();
@Query public int size(Class<?> clazz);
@Query public Object getByOId (Integer id);
@Query public Collection<?> getAll();
@Query public <T>Collection<T> getAll (Class<? extends T> clazz);
@Query public Collection<Integer> getOIds();
@Query public Collection<?> getObjectsByOId (Collection<Integer> ids);
@Query public <T>Collection<T> find ( QueryCriteria<? extends T> query
);
@TransactionWithQuery public Object storeOrUpdate (Object object) throws
RepositoryException;
@TransactionWithQuery public Object storeOrUpdate (Object object,
boolean index) throws RepositoryException;
@Transaction public void storeOrUpdate (Collection<?> object, boolean
index) throws RepositoryException;
@Transaction public void reindex() throws RepositoryException;
@Transaction public void reindex(Class<?> clazz) throws
RepositoryException;
@Transaction public void createIndex (Class<?> clazz, String indexPath);
@Transaction public void createIndex (Class<?> clazz, String indexPath,
boolean allowNulls);
@TransactionWithQuery public Object delete (Integer oid) throws
RepositoryException;
@TransactionWithQuery public Object executeDeterministic (Deterministic
action, Object ...args) throws Exception;
public void takeSnapshot();
|Are the Luncene indexes stored in the same Prevayler, or in Lucene's own
filesystem storage? Do you care about |transactional consistency between the
indexes and the data? (You might not.)
The Lucene indexes are stored in the same Prevayler. We keep the consistency
between the indexes and the data, but it is not mandatory. For example you
can store several objects in the repository and later execute a reindex. By
default when you store an object, the object (if you created an index for
the object type) is indexed. At this moment, the only validation we are
doing at indexing time is the null checking. For example:
Person p = new Person();
p.setName ("John");
repository.createIndex (Person.class, "lastName", false); // Index on
Person.lastName, not nulls allowed
repository.storeOrUpdate (p); // Throws an exception, p is not stored in the
repository.
To store an object and avoid the exception:
repository.createIndex (Person.class, "lastName", false); // Index on
Person.lastName, not nulls allowed
repository.storeOrUpdate (p, false); // Store the object
repository.reindex(Person.class); // Throws an exception
On the other hand, when you delete an object, if the object type has an
index definition, the index for that object is deleted.
Regards
Diego.
On Mon, May 18, 2009 at 8:48 PM, Justin T. Sampson <[email protected]>wrote:
> Hi Diego,
>
> Sounds cool.
>
> Does each method of PrevalenceRepository send a Query or Transaction to an
> underlying Prevayler instance?
>
> Are the Luncene indexes stored in the same Prevayler, or in Lucene's own
> filesystem storage? Do you care about transactional consistency between the
> indexes and the data? (You might not.)
>
> Cheers,
> Justin
>
> --
> Agile Focus - http://agilefocus.com/
>
>
>
> On Mon, May 18, 2009 at 2:03 PM, Diego Miranda <[email protected]>wrote:
>
>> Hi to all!
>>
>> We are using Prevayler in several projects. For those projects we've
>> created a Prevalent
>> Repository. This repository allows the objects to be queried and indexed
>> with Lucene.
>> We provide a query and indexing abstraction to simplify the search of the
>> objects stored
>> in the repository.
>>
>> Here, some examples:
>>
>> - Creating a Repository and storing data:
>>
>> PrevalenceRepository prevalence = PrevalenceRepository.newInstance();
>> Repository repository = prevalence.openRepository ("MyApp");
>>
>> repository.storeOrUpdate (person);
>> repository.storeOrUpdate (collectionOfPersons);
>>
>> - Creating index:
>>
>> repository.createIndex (Person.class, "addresses.state");
>> repository.createIndex (Person.class, "lastName");
>>
>> - Querying the objects:
>>
>> QueryCriteria query = from(Person.class).where(
>> and(eq("addresses.street", "Melo"),eq("lastName", "Smith"))
>> );
>> Collection<Person> persons = (Collection<Person>)repository.find(query);
>>
>>
>> - Deleting objects:
>>
>> repository.delete ( personOid )
>>
>> - Working with the repository data
>>
>> repository.executeDeterministic ( new DeterministicOperations (),
>> argument1, argument2 );
>>
>>
>> I'd like to know (if possible) what do you think about this!
>>
>> Best regards!
>> Diego Miranda
>> diego.miranda at gmail dot com
>>
>
>
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables
> unlimited royalty-free distribution of the report engine
> for externally facing server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> To unsubscribe go to the end of this page:
> http://lists.sourceforge.net/lists/listinfo/prevayler-discussion
> _______________________________________________
> "Databases in Memoriam" -- http://www.prevayler.org
>
>
--
Ley de Hofstadter: Siempre toma más tiempo del que se preveía, aun cuando se
toma en cuenta la Ley de Hofstadter.
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
To unsubscribe go to the end of this page: http://lists.sourceforge.net/lists/listinfo/prevayler-discussion
_______________________________________________
"Databases in Memoriam" -- http://www.prevayler.org