|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecthu.netmind.beankeeper.Store
public class Store
This store class is the entry point to the persistence library. To store, remove or select given objects, just use the appropriate methods.
| Constructor Summary | |
|---|---|
Store(javax.sql.DataSource dataSource)
Instantiate a store. |
|
Store(java.lang.String driverClass,
java.lang.String url)
Instantiate a store. |
|
| Method Summary | |
|---|---|
void |
close()
Close the store, and release all resources. |
java.util.List |
find(java.lang.String statement)
Query an object from the datastore. |
java.util.List |
find(java.lang.String statement,
java.lang.Object[] parameters)
Same as find(statement). |
java.lang.Object |
findSingle(java.lang.String statement)
Same as find(statement), but the result should be
a single object. |
java.lang.Object |
findSingle(java.lang.String statement,
java.lang.Object[] parameters)
Same as find(statement,parameters), but the result should be
a single object. |
ConfigurationTracker |
getConfigurationTracker()
Get the configuration tracker for this Store. |
EventDispatcher |
getEventDispatcher()
Get the event dispatcher in which the caller may register listeners. |
LockTracker |
getLockTracker()
Get the lock tracker. |
java.lang.Long |
getPersistenceId(java.lang.Object obj)
Get the persistence id for an object. |
PersistenceMetaData |
getPersistenceMetaData(java.lang.Object obj)
Get the persistence meta-data object for a given object. |
TransactionTracker |
getTransactionTracker()
Get the transaction tracker associated with this store. |
void |
remove(java.lang.Object obj)
Remove the object given. |
void |
save(java.lang.Object obj)
Save the given object to the store. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Store(java.lang.String driverClass,
java.lang.String url)
driverClass - The driver class to register.url - The driver's jdbc url (including username and password).public Store(javax.sql.DataSource dataSource)
| Method Detail |
|---|
public void close()
public TransactionTracker getTransactionTracker()
public ConfigurationTracker getConfigurationTracker()
public LockTracker getLockTracker()
public EventDispatcher getEventDispatcher()
public java.lang.Long getPersistenceId(java.lang.Object obj)
getPersistenceMetaData(obj).getPersistenceId().
public PersistenceMetaData getPersistenceMetaData(java.lang.Object obj)
public void save(java.lang.Object obj)
obj - The object to save.
StoreException - If save is not successfull.public void remove(java.lang.Object obj)
obj - The object to remove.
StoreException - If remove is not successfull.public java.util.List find(java.lang.String statement)
find book where book.name='Snow Crash'The statement always starts with the keyword 'find', and all keywords and parts of the statement not between apostrophs are case in-sensitive.
find book where book.author=author and author.birthdate=1959Of course Book, and Author classes must exits in the store with given attributes. Note also, that the above statement can be simply written:
find book where book.author.birthdate=1959You can name the classes you are referencing for later use (handy if you must "join" the class with itself):
find book where book.author=otherbook(book).author and otherbook.name='Snow Crash'Here, the "otherbook" does not refer to a class, it is only another name for the class book, and means, that is should be not the same instance as the one referenced with "book".
find movie where movie.startdate > nowThis also means, that attributes named 'now' must be escaped (prefixed with it's table name).
find book where ((book.author.firstname='Neal') and (book.author.lastname='Stephenson'))
find book where book.genres contains genre and genre.name='postcyberpunk'
find author where author.books contains book and book.name='Snow Crash'A container operator can not be negated, an exception will be thrown, if the expression would try to do that.
find book where book.metadata['author']=author and author.name='Neal StephensonHowever, if after a map operator an attribute is referenced, there is a mandatory class specifier:
find book where book.metadata['author'](author).name='Neal Stephenson
find book order by book.name ascThe order by command takes attributes as aguments. You can give more than one attribute separated by commas. Also you can append 'asc' (ascending) or 'desc' (descending) to mark the direction of sort.
find book order by book.author.name asc, book.name descNote, that method will silently return an empty list, if the specified table or one specified in where clause does not exist.
statement - The query statement to select.
public java.util.List find(java.lang.String statement,
java.lang.Object[] parameters)
find(statement). When a statement contains
the question mark (?), the object which should be in the place of
the mark should be given as parameters (parameters are usually of
Date, or custom classes).
statement - The query statement to execute.parameters - The parameters.
public java.lang.Object findSingle(java.lang.String statement,
java.lang.Object[] parameters)
find(statement,parameters), but the result should be
a single object.
statement - The query statement to execute.parameters - The parameters to the statement.
public java.lang.Object findSingle(java.lang.String statement)
find(statement), but the result should be
a single object.
statement - The query statement to execute.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||