BX-ORM
  • Introduction
    • Release History
      • 1.x
    • About This Book
  • Getting Started
    • Installation
    • Configuration
      • Custom Hibernate Config
      • Secondary Caches
      • Logging
  • Modeling
    • Entities
    • Identifiers
    • Properties
    • Relationships
  • Usage
    • Built-In Functions
    • Querying
    • Events
    • Session Management
    • HQL
    • Transactions
    • Caching
  • External Links
    • ForgeBox
    • API docs
    • Source Code
    • Issue Tracker
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
Export as PDF
  1. Modeling

Entities

Learn the basics of modeling ORM entities

A persistent entity is a boxlang class that is marked as a database entity via the persistent annotation upon the class definition:

class persistent="true"{

}

By default, the entity name will be the boxlang class file name - minus the file extension, of course. We can modify the entity name via the entityname annotation:

class persistent="true" entityname="Author" {

}

And the table name via the table annotation:

class persistent="true" entityname="Author" table="authors" {

}

Here's the full list of available annotations for a persistent class:

Attribute
Type
Default
Description

persistent

boolean

false

Mark this class as an ORM entity

entityname

string

Set a custom entity name which is different than the boxlang class name

table

string

Specify the database table name

schema

string

Specify the database schema name.

catalog

string

Specify the database catalog name.

dynamicinsert

Specifies whether INSERT SQL is to be generated at runtime. Only those columns whose values are not null are included in the SQL.

dynamicinsert

boolean

false

Specifies whether INSERT SQL is to be generated at runtime. Only those columns whose values are not null are included in the SQL.

dynamicupdate

boolean

false

Specifies whether UPDATE SQL is to be generated at runtime. Only those columns whose values are not null are included in the SQL.

readonly

boolean

false

Specify whether table is readonly or not

selectbeforeupdate

boolean

Specify whether Hibernate should never perform an SQL UPDATE unless it is certain that an object is actually modified. In cases when a transient object is associated with a new session using update(), Hibernate performs an extra SQL SELECT to determine if an UPDATE is actually required.

optimisticlock

string

Determines the locking strategy. It can be any one of:all,dirty,version,none

batchsize

integer

An integer value that specifies the number of records to be retrieved at a single instance.

lazy

boolean

true

Whether loading is to be done lazily or not.

rowid

string

Specify the row id

discriminatorColumn

string

Use this attribute to define the discriminator column to be used in inheritance mapping

discriminatorValue

string

Use this attribute to define the discriminator value to be used in inheritance mapping

joinColumn

string

Define a join column for inheritance mapping

embedded

boolean

Marks class as embedded, used when a class has an embedded object which also needs to be persisted along with the parent's data

cacheUse

string

Specify the caching strategy to be used for caching this entity's data in the secondary cache:read-only

cacheName

string

Specify the name of the secondary cache

saveMapping

boolean

false

Specifies whether the generated Hibernate mapping file has to be saved to disk. If you set the value to true, the Hibernate mapping XML file is saved as {class name}.hbm.xml in the same directory as the boxlang class.

datasource

string

Name a specific datasource to persist this entity to.

PreviousLoggingNextIdentifiers

Last updated 2 months ago

Was this helpful?