hibernate Namespace

Namespace URI: http://www.xchain.org/hibernate/1.0

This namespace provides access to hibernate. A hibernate.cfg.xml must be present to properly establish a connection to a datasource.

Most hibernate commands are required to be within an active session .

Available Commands

debug-session

Attributes
NameDescriptionTypeDefault ValueJava Return Type
nameorg.xchain.annotations.AttributeType.QNAME{http://www.xchain.org/hibernate}session-factoryQName
messageorg.xchain.annotations.AttributeType.ATTRIBUTE_VALUE_TEMPLATEString

delete

Attributes
NameDescriptionTypeDefault ValueJava Return Type
nameorg.xchain.annotations.AttributeType.QNAME{http://www.xchain.org/hibernate}session-factoryQName
selectAn XPath to the entity to delete.org.xchain.annotations.AttributeType.JXPATH_VALUEN/AObject
select-nodesAn XPath to a list of entities to delete.org.xchain.annotations.AttributeType.JXPATH_SELECT_NODESN/AList
select-single-nodeAn XPath to a the entity to delete.org.xchain.annotations.AttributeType.JXPATH_SELECT_SINGLE_NODEN/AObject

The delete command deletes the provided entity or list of entities.

This must reference an active session .

<xchain:session xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  ...
  <xchain:delete select="/some/xpath"/>
  ...
 </xchain:session>

first-result

Attributes
NameDescriptionTypeDefault ValueJava Return Type
queryThe location of the query to use.org.xchain.annotations.AttributeType.JXPATH_VALUE$hibernate:queryQuery
startThe start index to retrieve results.org.xchain.annotations.AttributeType.JXPATH_VALUEN/AInteger

The first-result command sets the FirstResult on the parent Query.

This must reference a query .

<xchain:session xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  <xchain:transaction>
    ...
    <xchain:query query="'from entity'">
      ...
      <xchain:first-result start="'10'"/>
      ...
    </xchain:query>
    ...
  </xchain:transaction>
 </xchain:session>

get

Attributes
NameDescriptionTypeDefault ValueJava Return Type
nameorg.xchain.annotations.AttributeType.QNAME{http://www.xchain.org/hibernate}session-factoryQName
idID of the entity to retrieve.org.xchain.annotations.AttributeType.JXPATH_VALUEN/ASerializable
class-nameThe class of the entity to retrieve.org.xchain.annotations.AttributeType.JXPATH_VALUEN/AString
resultWhere to store the retrieved entity.org.xchain.annotations.AttributeType.QNAMEN/AString
variableVariable of where to store the entity.org.xchain.annotations.AttributeType.QNAMEN/AString
scopeScope of the variable storing the entity.org.xchain.annotations.AttributeType.LITERALexecutionScope

The get command starts executes the Get method on the current session. The class-name attribute identifies the class to be loaded. The id attribute identifies the unique identifier for the class to be loaded.

This must reference an active session .

<xchain:session xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  <xchain:transaction>
    ...
    <xchain:get id="'1'" class-name="'my.package.entity'" variable="result" scope="request"/>
    ...
  </xchain:transaction>
 </xchain:session>

iterate

Attributes
NameDescriptionTypeDefault ValueJava Return Type
queryThe location of the query to use.org.xchain.annotations.AttributeType.JXPATH_VALUE$hibernate:queryQuery
resultThe QName of where to store the result. The QName must already exist.org.xchain.annotations.AttributeType.QNAMEN/AString
variableThe variable of where to store the result. If the variable does not yet exist, a variable will be declared.org.xchain.annotations.AttributeType.QNAMEN/AString
scopeThe scope of the variable.org.xchain.annotations.AttributeType.LITERALexecutionScope

The iterate evaluates the Query as an iterator.

This must reference a query .

<xchain:session xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  <xchain:transaction>
    ...
    <xchain:query query="'from Entity'">
      ...
      <xchain:iterate result="$myIterator"/>
      ...
    </xchain:query>
    ...
  </xchain:transaction>
 </xchain:session>

list

Attributes
NameDescriptionTypeDefault ValueJava Return Type
queryThe location of the query to use.org.xchain.annotations.AttributeType.JXPATH_VALUE$hibernate:queryQuery
resultThe QName of where to store the result. The QName must already exist.org.xchain.annotations.AttributeType.QNAMEN/AString
variableThe variable of where to store the result. If the variable does not yet exist, a variable will be declared.org.xchain.annotations.AttributeType.QNAMEN/AString
scopeThe scope of the variable.org.xchain.annotations.AttributeType.LITERALexecutionScope

The list evaluates the Query as a list.

This must reference a query .

<xchain:session xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  <xchain:transaction>
    ...
    <xchain:query query="'from Entity'">
      ...
      <list result="$myList"/>
      ...
    </xchain:query>
    ...
  </xchain:transaction>
 </xchain:session>

max-result

Attributes
NameDescriptionTypeDefault ValueJava Return Type
queryThe location of the query to use.org.xchain.annotations.AttributeType.JXPATH_VALUE$hibernate:queryQuery
sizeThe maximum number of entries.org.xchain.annotations.AttributeType.JXPATH_VALUEN/AInteger

The max-result command sets the MaxResults on the parent Query.

This must reference a query .

<xchain:session xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  <xchain:transaction>
    ...
    <xchain:query query="'from entity'">
      ...
      <xchain:max-result start="'10'"/>
      ...
    </xchain:query>
    ...
  </xchain:transaction>
 </xchain:session>

parameter

Attributes
NameDescriptionTypeDefault ValueJava Return Type
queryThe location of the query to use.org.xchain.annotations.AttributeType.JXPATH_VALUE$hibernate:queryQuery
nameThe name of the parameter in the query.org.xchain.annotations.AttributeType.JXPATH_VALUEN/AString
valueThe value of the parameter in the query.org.xchain.annotations.AttributeType.JXPATH_VALUEN/AObject

The parameter command will specify a parameter for a query.

This must reference a query .

<xchain:session xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  <xchain:transaction>
    ...
    <xchain:query query="'from entity where value = :myvalue'">
      ...
      <xchain:parameter name="'myvalue'" value="/some/xpath"/>
      ...
    </xchain:query>
    ...
  </xchain:transaction>
 </xchain:session>

persist

Attributes
NameDescriptionTypeDefault ValueJava Return Type
nameorg.xchain.annotations.AttributeType.QNAME{http://www.xchain.org/hibernate}session-factoryQName
entityThe entity to persist.org.xchain.annotations.AttributeType.QNAMEN/AString

The persist command will execute a Hibernate persist on the session with the specified entity. For more information about the persist method, refer to the Hibernate documentation.

This must reference an active session .

<xchain:session xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  <xchain:transaction>
    ...
    <xchain:persist entity="$myEntity">
    ...
  </xchain:transaction>
 </xchain:session>

query

Attributes
NameDescriptionTypeDefault ValueJava Return Type
nameorg.xchain.annotations.AttributeType.QNAME{http://www.xchain.org/hibernate}session-factoryQName
resultWhere the query is stored.org.xchain.annotations.AttributeType.QNAME{http://www.xchain.org/hibernate/1.0}queryQName
queryThe actual HQL query.org.xchain.annotations.AttributeType.JXPATH_VALUEN/AString

The query command starts a new query.

This must reference an active session .

<xchain:session xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  <xchain:transaction>
    ...
    <xchain:query query="'from entity'">
      ...
    <xchain:query/>
    ...
  </xchain:transaction>
 </xchain:session>

save

Attributes
NameDescriptionTypeDefault ValueJava Return Type
nameorg.xchain.annotations.AttributeType.QNAME{http://www.xchain.org/hibernate}session-factoryQName
entityThe entity to save.org.xchain.annotations.AttributeType.QNAMEN/AString

The save command will execute a Hibernate save on the session with the specified entity. For more information about the save method, refer to the Hibernate documentation.

This must reference an active session .

<xchain:session xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  <xchain:transaction>
    ...
    <xchain:save entity="$myEntity">
    ...
  </xchain:transaction>
 </xchain:session>

session

Attributes
NameDescriptionTypeDefault ValueJava Return Type
resultWhere the session is stored.org.xchain.annotations.AttributeType.QNAME{http://www.xchain.org/hibernate/1.0}sessionQName
nameorg.xchain.annotations.AttributeType.QNAME{http://www.xchain.org/hibernate}session-factoryQName

NOTE: The hibernate session command is currently broken. This implementation will create duplicate sessions when used with the HibernateLifecycle.getCurrentSession() function. This tag will be removed in the 0.4.0 version of XChains.

The session command creates a new Hibernate session and stores it into the context. The location of the session in the context is determined by the result attribute.

Once the session command is complete, the Hibernate session will be closed.

<xchain:session xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  ...
 </xchain:session>

transaction

Attributes
NameDescriptionTypeDefault ValueJava Return Type
timeoutThe timeout of queries on this transaction in seconds.org.xchain.annotations.AttributeType.JXPATH_VALUE\90\Integer
propagate-resultWhether to continue the chain of command based on the children's result.org.xchain.annotations.AttributeType.JXPATH_VALUE\false\Boolean
nameorg.xchain.annotations.AttributeType.QNAME{http://www.xchain.org/hibernate}session-factoryQName

The transaction command starts a Hibernate transaction. Any children commands will be run within the context of this transaction. When all children commands have been executed, the transaction will be committed unless any exceptions are thrown up to this command. If an unhandled exception is encountered the transaction will be rolled back.

If the propagate-result attribute is true then the chain of command will continue if and only if the children commands would continue the chain of command. If the propagate-result attribute is false then the chain of command will continue regardless of the result of the children commands.

This must reference an active session .

<xchain:session xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  <xchain:transaction>
    ...
  </xchain:transaction>
 </xchain:session>

unique-result

Attributes
NameDescriptionTypeDefault ValueJava Return Type
queryThe location of the query to use.org.xchain.annotations.AttributeType.JXPATH_VALUE$hibernate:queryQuery
resultThe QName of where to store the result. The QName must already exist.org.xchain.annotations.AttributeType.QNAMEN/AString
variableThe variable of where to store the result. If the variable does not yet exist, a variable will be declared.org.xchain.annotations.AttributeType.QNAMEN/AString
scopeThe scope of the variable.org.xchain.annotations.AttributeType.LITERALexecutionScope

The unique-result evaluates a query as a uniqueResult.

This must reference a query .

<xchain:session xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  <xchain:transaction>
    ...
    <xchain:query query="'from Entity where value = 1'">
      ...
      <unique-result result="$myEntity"/>
      ...
    </xchain:query>
    ...
  </xchain:transaction>
 </xchain:session>

update

Attributes
NameDescriptionTypeDefault ValueJava Return Type
queryThe location of the query to use.org.xchain.annotations.AttributeType.JXPATH_VALUE$hibernate:queryQuery
resultThe QName of where to store the result. The QName must already exist.org.xchain.annotations.AttributeType.QNAMEN/AString
variableThe variable of where to store the result. If the variable does not yet exist, a variable will be declared.org.xchain.annotations.AttributeType.QNAMEN/AString
scopeThe scope of the variable.org.xchain.annotations.AttributeType.LITERALexecutionScope

The update executes the query as an update.

This must reference a query .

<xchain:session xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  <xchain:transaction>
    ...
    <xchain:query query="'update Entity set value = 1 where value = 1'">
      ...
      <xchain:update result="$myEntity"/>
      ...
    </xchain:query>
    ...
  </xchain:transaction>
 </xchain:session>

validate

Attributes
NameDescriptionTypeDefault ValueJava Return Type
selectThe entity to validate.org.xchain.annotations.AttributeType.JXPATH_VALUEN/AObject
select-nodesA list of entities to validate.org.xchain.annotations.AttributeType.JXPATH_SELECT_NODESN/AList
select-single-nodeThe entity to validate.org.xchain.annotations.AttributeType.JXPATH_SELECT_SINGLE_NODEN/AObject
validation-messagesWhere to store the validation messages.org.xchain.annotations.AttributeType.QNAME{http://www.xchain.org/hibernate/1.0}validation-messagesQName

The validate command ensures that objects have their proper hibernate restrictions. If the objects are valid then the child valid command is executed. If the objects are invalid then the child invalid command is executed.

<xchain:validate select="/some/xpath" xmlns:xchain="http://www.xchain.org/hibernate/1.0">
  <xchain:valid>
   ...
  </xchain:valid>
  <xchain:invalid>
   ...
  </xchain:invalid>
 </xchain:session>

invalid

The invalid command chain is executed if the parent validation command fails.

valid

The valid command chain is executed if the parent validation command passes.