Optional Settings

ExpandedToggleIcon        Versioned Data

When it is necessary to implement optimistic concurrency control, then NHibernate Version is used. If optimistic concurrency control and locking are disabled, the application uses "Last commit wins" strategy. Under this approach the loss of data updates is possible, in case several transactions are making changes to same object simultaneously. There is a better strategy that is called "First commit wins". Under this approach the second transaction will fail with an error like "The data have already been modified. Please refresh the page to see the changes."

To indicate that this property is the timestamp of the latest changes in the record, select the Version check box. Note that the type of the version property must be Int64, Int32, Int16, Ticks, Timestamp, or TimeSpan. If some other type is selected, an appropriate warning message will be displayed after OK is clicked.

 

ExpandedToggleIcon        Formula Specifics

Computed properties are properties, that are computed during the runtime. That means that this kind of properties has no direct mapping to the computed field, and can contain data computed by some formula. The Formula field enables specifying a SQL expression that defines the value for a computed property, instead of specifying the column in the Column box.

For example, if you want to assign 0 as the value of the property, when the class type is a, b, c, and 1 otherwise, you can enter the following formula:

case when CLASS_TYPE in ('a', 'b', 'c') then 0 else 1 end

 

ExpandedToggleIcon        Unsaved Value

It is a property value which indicates that an instance is newly instantiated (unsaved), distinguishing it from detached instances that were saved or loaded in a previous session.

The Unsaved value field is available only for primary key or version properties (for them the Version property is set to True).

The allowed values of unsaved value are:

any - always save.

none - always update.

null - save when identifier is null.

valid identifier value - save when identifier is null or the given value.

undefined - if set for version or timestamp, then identifier check is used.

If unsaved value is not specified for a class, NHibernate will make an attempt to guess it by creating an instance of the class using the no-argument constructor and reading the property value from the instance.

 

ExpandedToggleIcon        Properties Generated by Database

Properties generated by database are properties which have their values generated by the database. Marking properties as generated by database delegates the responsibility of objects refresh to NHibernate. Essentially, whenever NHibernate issues an SQL INSERT or UPDATE for an entity which has properties defined as generated by database, it immediately issues a select afterwards to retrieve the generated values.

Properties marked as generated by database must additionally be non-insertable and non-updateable. Only version, timestamp, and persistent properties can be marked as generated by database.

The Generated By Database drop-down list specifies that this property value is actually generated by the database. Acceptable values are Never, Insert, and Always.

Never (the default) - means that the given property value is not generated within the database.

Insert - states that the given property value is generated on insert, but is not regenerated on subsequent updates. Things like created-date would fall into this category.

Always - states that the property value is generated both on insert and on update.

The Insert check box specifies that the mapped columns should be included in SQL INSERT statements.

The Update check box specifies that the mapped columns should be included in SQL UPDATE statements.

The Optimistic Lock check box specifies that updates to this property do or do not require acquisition of the optimistic lock.

 


Send feedback on this topic

© 2008 - 2024 Devart. All rights reserved.