|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectflex.data.assemblers.AbstractAssembler
flex.data.assemblers.HibernateAssembler
public class HibernateAssembler
An assembler that provides support for hibernate entities as flex destinations in Flex Data Management Services. You can use this class out of the box, or you can extend it get complete control over how your persistence functionality is exposed to clients. You can also add your own fill and count methods to a subclass and refer to them from the configuration file.
| Field Summary | |
|---|---|
static String |
LOG_CATEGORY
Log category for HibernateAssembler. |
| Fields inherited from interface flex.data.adapters.JavaAdapterConstants |
|---|
AUTO_REFRESH_ELEMENT, CONFLICT_MODE_DEFAULT, CONFLICT_MODE_DELETE_ATTR, CONFLICT_MODE_UPDATE_ATTR, COUNT_ELEMENT, FILL_CONTAINS_METHOD_ELEMENT, FILL_ELEMENT, GET_ELEMENT, METHOD_NAME_ELEMENT, ORDERED_ELEMENT, PARAM_TYPES_ELEMENT, SECURITY_CONSTRAINT_ELEMENT, SECURITY_REF_ATTR, SECURITY_RUN_AS_ELEMENT, SYNC_ELEMENT |
| Fields inherited from interface flex.data.assemblers.Assembler |
|---|
APPEND_TO_FILL, DO_NOT_EXECUTE_FILL, EXECUTE_FILL, REMOVE_FROM_FILL |
| Constructor Summary | |
|---|---|
HibernateAssembler()
The Assembler class is constructed by Data Management Services so you do not need to construct this yourself. |
|
| Method Summary | |
|---|---|
boolean |
autoRefreshFill(List fillParameters)
The Hibernate assembler always refreshes fill methods automatically so this method returns true for all fills. |
int |
count(List countParams)
Implements the count queries for the hibernate assembler. |
void |
createItem(Object item)
Actually performs the createItem operation. |
void |
deleteItem(Object clientVersion)
Deletes the hibernate item. |
Collection |
fill(List fillArgs,
int startIndex,
int numItems)
Implements the fill method for the hibernate assembler. |
String |
getDeleteConflictMode()
Returns the delete-conflict-mode of the HibernateAssembler. |
String |
getHibernateConfigFile()
Returns the hibernate-config-file of the HibernateAssembler. |
String |
getHibernateEntity()
Returns hibernate-entity of the HibernateAssembler. |
Object |
getItem(Map identity)
Returns the item for the specified identity. |
boolean |
getPageQueriesFromDatabase()
Set this to true if you want to page queries for this destination directly from the database. |
String |
getUpdateConflictMode()
Returns the update-conflict-mode/code> of the |
void |
initialize(String id,
ConfigMap properties)
This initialize method is called once for each destination. |
boolean |
isAllowHQLQueries()
Returns if hql queries are allowed or not. |
boolean |
isUseQueryCache()
Returns if hibernate's query cache is enabled. |
int |
refreshFill(List fillParameters,
Object item,
boolean isCreate)
The hibernate assembler refreshes all outstanding fills whenever any item is created or modified. |
void |
setAllowHQLQueries(boolean allowHQLQueries)
Sets if hql queries are allowed or not. |
void |
setDeleteConflictMode(String deleteConflictMode)
Sets the delete-conflict-mode of the HibernateAssembler. |
void |
setHibernateConfigFile(String hibernateConfigFile)
Sets the hibernate-config-file of the HibernateAssembler. |
void |
setHibernateEntity(String hibernateEntity)
Sets hibernate-entity of the HibernateAssembler. |
void |
setPageQueriesFromDatabase(boolean pfdb)
|
void |
setUpdateConflictMode(String updateConflictMode)
Sets the update-conflict-mode of the HibernateAssembler. |
void |
setUseQueryCache(boolean useQueryCache)
Sets whether hibernate's query cache is enabled. |
void |
start()
The default implementation simply sets started property
to true. |
void |
stop()
The default implementation simply sets started property
to false. |
void |
updateItem(Object newItem,
Object prevItem,
List changes)
This method is called to update an item in hibernate. |
boolean |
useFillPage(List fillParameters)
This method returns true for any queries which implement the page-by-page method for filling collections. |
| Methods inherited from class flex.data.assemblers.AbstractAssembler |
|---|
addItemToFill, fill, getItems, isStarted, refreshFillStatusToName, removeItemFromFill |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String LOG_CATEGORY
HibernateAssembler.
| Constructor Detail |
|---|
public HibernateAssembler()
| Method Detail |
|---|
public void initialize(String id,
ConfigMap properties)
The hibernate assembler uses two utility classes. The HibernateManager is a class which is created for each hibernate configuration file you specify. It manages the Data Management Services state for a group of related hibernate entitites. The HibernateType class is created for each assembler instance.
initialize in interface FlexConfigurableinitialize in class AbstractAssemblerid - the destination name for this assembler.properties - the properties used to configure this destination underneath
the properties tag.public void start()
AbstractAssemblerstarted property
to true. Subclasses should call super.start().
start in interface FlexComponentstart in class AbstractAssemblerpublic void stop()
AbstractAssemblerstarted property
to false. Subclasses should call super.stop().
stop in interface FlexComponentstop in class AbstractAssemblerpublic boolean isAllowHQLQueries()
true if hql queries are allowed, false
otherwise.public void setAllowHQLQueries(boolean allowHQLQueries)
true, allows
clients to directly execute hql statements. This is useful for prototyping
but is not recommended for production deployment due to the potential for
untrusted code to execute queries it chooses in your deployment.
allowHQLQueries - public boolean getPageQueriesFromDatabase()
If the client is paging to the database, there are two ways the size of the collection can be determined. The count method is called with the same set of fill parameters used by the fill method for this collection. If count returns -1 (the default), the array collection on the client will be dynamically sized. In this mode, the query fetches one more than the number of items requested by the page. If the query hits the end of the list, the collection size is known and set on the page response. If the query returns the one plus the page size items we requested, the collection size is set to include that extra item we fetched in the last page fetched. This extra item is not returned to the client however. When the client requests the page containing the one missing item, the next page is fetched which again requests one more than the page size.
If you want your client to know the correct size of the collection on the first page request, you need to provide a count method which takes the same set of fill parameters as the fill method that returns an accurate count. (For dynamically sized queries, the count method returns -1). for each query you define for a given "name", provide a "name.count" query which returns the number of items in the query. For HQL queries specified on the client, if the query starts with "from" we turn that query into a count query automatically by prepending the "select count(*)" string onto the query.
public void setPageQueriesFromDatabase(boolean pfdb)
public String getDeleteConflictMode()
delete-conflict-mode of the HibernateAssembler.
If the Hibernate entity class is configured to use Hibernate's automatic version
or timestamp based concurrent conflict detection, that will override the
configured conflict detection mode.
delete-conflict-modepublic void setDeleteConflictMode(String deleteConflictMode)
delete-conflict-mode of the HibernateAssembler.
Valid values are NONE and OBJECT.
If the Hibernate entity class is configured to use Hibernate's automatic version
or timestamp based concurrent conflict detection, that will override the
configured conflict detection mode.
deleteConflictMode - delete-conflict-modepublic String getHibernateEntity()
hibernate-entity of the HibernateAssembler.
hibernate-entity.public void setHibernateEntity(String hibernateEntity)
hibernate-entity of the HibernateAssembler.
Optional. If not present, the adapter will assume that the Hibernate
entity has the same name as the destination id. This property cannot be
changed after startup.
hibernateEntity - public String getHibernateConfigFile()
hibernate-config-file of the HibernateAssembler.
hibernate-config-file.public void setHibernateConfigFile(String hibernateConfigFile)
hibernate-config-file of the HibernateAssembler.
If no config file is specified, then Hibernate uses its de facto standard
hibernate.cfg.xml. This property cannot be changed after
startup.
hibernateConfigFile - hibernate-config-file.public String getUpdateConflictMode()
update-conflict-mode/code> of the HibernateAssembler.
If the Hibernate entity class is configured to use Hibernate's automatic version
or timestamp based concurrent conflict detection, that will override the
configured conflict detection mode.
- Returns:
update-conflict-mode/code>
public void setUpdateConflictMode(String updateConflictMode)
update-conflict-mode of the HibernateAssembler.
Valid values are NONE, PROPERTY, and OBJECT.
If the Hibernate entity class is configured to use Hibernate's automatic version
or timestamp based concurrent conflict detection, that will override the
configured conflict detection mode.
updateConflictMode - update-conflict-modepublic boolean isUseQueryCache()
true if hibernate's query cache is enabled,
false otherwise.public void setUseQueryCache(boolean useQueryCache)
useQueryCache - public int count(List countParams)
count in interface Assemblercount in class AbstractAssemblercountParams - a list of parameters to the count method provided by the
client invocation.
public Object getItem(Map identity)
getItem in interface AssemblergetItem in class AbstractAssembleridentity - a java.util.Map which contains key/value pairs for
each identity property.
public Collection fill(List fillArgs,
int startIndex,
int numItems)
If the destination configuration sets the allow-hql-queries attribute to true, your client can also pass in arbitrary HQL queries. In this case, the first parameter is the string token: "flex:hql", the second parameter is the HQL string and the third parameter specifies the parameter set for the queries as either an array or a java.util.Map.
You can override this method to add additional queries or augment how hibernate queries are implemented in general.
fill in interface Assemblerfill in class AbstractAssemblerfillArgs - the list of fill parameters provided to the DataService.fill
method on the client. Note that the first parameter - the ArrayCollection is not
included in this list.startIndex - the index in the fill collection from which this method will start
retrieving records. The first record starts at 0, not 1 as is used in JDBC.
If startIndex is -1, you should return the entire collection.numItems - the number of recrods retrieved by this method
public boolean useFillPage(List fillParameters)
useFillPage in interface AssembleruseFillPage in class AbstractAssemblerfillParameters - the list of fill parameters provided to the DataService.fill
method on the client. Note that the first parameter - the ArrayCollection is not
included in this list.public boolean autoRefreshFill(List fillParameters)
autoRefreshFill in interface AssemblerautoRefreshFill in class AbstractAssemblerfillParameters - Client-side parameters to a fill method that
created a managed collection still managed by one or more clients.
public int refreshFill(List fillParameters,
Object item,
boolean isCreate)
refreshFill in interface AssemblerrefreshFill in class AbstractAssemblerfillParameters - the parameters which identify a fill method that
is still actively being managed by one or more clients connected to this
server.item - The item which is being created or updated in a recently committed
transactino.isCreate - true if this item was just created operation, false if it was just
updated.
public void createItem(Object item)
createItem in interface AssemblercreateItem in class AbstractAssembleritem - the initial instance of the item to create.
public void updateItem(Object newItem,
Object prevItem,
List changes)
updateItem in interface AssemblerupdateItem in class AbstractAssemblernewItem - the new version of the item with which to perform the updateprevItem - the original version of the item before these changes were
made (used for conflict detection).changes - the list of changed property names.public void deleteItem(Object clientVersion)
deleteItem in interface AssemblerdeleteItem in class AbstractAssemblerclientVersion - the original version of the item on the client which
the client intends to remove
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/lcdsjavadoc/flex/data/assemblers/HibernateAssembler.html