All pages
Powered by GitBook
1 of 9

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

clear

Clear the session removes all the entities that are loaded or created in the session. This clears the first level cache and removes the objects that are not yet saved to the database.

Returns

  • This function returns the base service reference (this)

Arguments

Examples

evict

Evict entity object(s) from the hibernate session or first-level cache.

  • An entity object

  • An array of entity objects

ORM Session

Key

Type

Required

Default

Description

datasource

string

false

---

The default or specific datasource use

ormService.clear();
Returns
  • This function returns void

Arguments

Key

Type

Required

Description

entities

any

Yes

The argument can be one persistence entity or an array of entities to evict

Examples

ormService.evict( thisEntity );

evictCollection

Evict all the collection or association data for a given entity name and collection name from the secondary cache ONLY, not the hibernate session.

Evict an entity name with or without an ID from the secondary cache ONLY, not the hibernate session

Returns

  • This function returns void

Arguments

Examples

id

any

false

The id to use for eviction according to entity name or relation name

Key

Type

Required

Default

Description

entityName

string

Yes

---

The entity name to evict or use in the eviction process

relationName

string

false

The name of the relation in the entity to evict

isSessionDirty

Checks if the session contains dirty objects that are awaiting persistence

Returns

  • This function returns boolean

Arguments

Examples

evictQueries

Evict all queries in the default cache or the cache region that is passed in.

Returns

  • This function returns void

merge

Merge an entity or array of entities back into the session

Returns

  • Same entity if one passed, array if an array of entities passed.

Key

Type

Required

Default

Description

datasource

string

false

---

The default or specific datasource to use

// Check if by this point we have a dirty session, then flush it
if( ormService.isSessionDirty() ){
  ORMFlush();
}
Arguments

Key

Type

Required

Default

Description

entity

any

Yes

---

Examples

// merge a single entity back
ormService.merge( userEntity );
// merge an array of entities
collection = [entity1,entity2,entity3];
ormService.merge( collection );
Arguments

Key

Type

Required

Default

Description

cacheName

string

No

---

datasource

string

No

---

Examples

getSessionStatistics

Information about the first-level (session) cache for the current session

Returns

  • This function returns struct

Arguments

Examples

sessionContains

Checks if the current hibernate session contains the passed in entity.

Returns

  • This function returns boolean

Arguments

Examples

// evict queries that are in the default hibernate cache
ormService.evictQueries();
// evict queries for this service
ormService.evictQueries( ormService.getQueryCacheRegion() );
// evict queries for my artists
ormService.evictQueries( "MyArtits" );

The datasource to use

Key

Type

Required

Default

Description

datasource

string

false

---

The default or specific datasource use

Key

Type

Required

Default

Description

entity

any

Yes

---

// Let's get the session statistics
stats = ormService.getSessionStatistics;

// Lets output it
<cfoutput>
collection count: #stats.collectionCount# <br/>
collection keys: #stats.collectionKeys# <br/>
entity count: #stats.entityCount# <br/>
entity keys: #stats.entityKeys#
</cfoutput>
function checkSomething( any User ){
  // check if User is already in session
  if( NOT ormService.sessionContains( arguments.User ) ){
     // Not in hibernate session, so merge it in.
     ormService.merge( arguments.User );
  }
}