hibernated.annotations

HibernateD - Object-Relation Mapping for D programming language, with interface similar to Hibernate.

Hibernate documentation can be found here: http://hibernate.org/docs

Source file hibernated/annotations.d.

This module contains declarations of HibernateD Annotations - User Defined Attribues used to markup D classes and their properties for ORM.

Members

Structs

Column
struct Column

Mark property as simple persistent property (must be of one of simple types).

Embeddable
struct Embeddable

@Embeddable or @Embeddable() - mark class as entity which can only be embedded into other entities, and doesn't have separate columns. Columns for each of Embeddable entity properties will be placed into parent entity's table, where this embeddable entity is embedded

Entity
struct Entity

Mark class with this annotation if you want to make it persistable. @Entity or @Entity() - marks class as entity, using class name as entity name.

Generated
struct Generated

@Generated or @Generated() - mark simple property as column as server generated value (e.g. AUTO INCREMENT field)

Generator
struct Generator

@Generator(code) - specify code to call for generation of simple property key value (will be inserted into definition Variant function(Connection conn, PropertyInfo prop) { return Variant($code); }

Id
struct Id

@Id or @Id() - mark simple property as primary key of entity.

JoinColumn
struct JoinColumn

@JoinColumn(columnName) - specify foreign key column name to join other entity's by its primary key - for @OneToOne relation. @JoinColumn or @JoinColumn() - foreign key column name will be autogenerated from referenced entity name, with _fk suffix. This annotation is mandatory if property has @OneToOne annotation w/o parameter or @ManyToOne annotation

ManyToMany
struct ManyToMany

@ManyToMany(joinTableName, joinColumn1, joinColumn2) - referenced objects use many-to-many relation via additional join table, requires additional parameters to specify join table to implement relation, and fk columns to referene this and related entities. @ManyToMany or @ManyToMany() - referenced objects use many-to-many relation via additional join table, will autogenerate join table name to implement relation, and fk column names to referene this and related entities.

ManyToOne
struct ManyToOne

@ManyToOne or @ManyToOne() - referenced object uses many-to-one relation, requires additional @JoinColumn annotation to specify foreign key column in current entity to join with current entity's primary key.

NotNull
struct NotNull

@NotNull or @NotNull() - mark entity property as not null (NULLs are not allowed in DB) If neither @NotNull nor @Null specified, nullability will be derived from field type (e.g. NotNull for int, long; Null for string, byte[], Nullable!int)

Null
struct Null

@Null or @Null() - mark entity property as nullable (NULLs are allowed in DB) If neither @NotNull nor @Null specified, nullability will be derived from field type (e.g. NotNull for int, long; Null for string, byte[], Nullable!int)

OneToMany
struct OneToMany

@OneToMany(referencedProperty) - referenced objects use one-to-many relation, requires additional property name in target entity which has specified foreign key column and ManyToOne to join with current entity's primary key.

OneToOne
struct OneToOne

@OneToOne(propertyName) - referenced object uses one-to-one relation, propertyName is referenced entity's property to join with current entity's primary key. @OneToOne or @OneToOne() - referenced object uses one-to-one relation, requires additional @JoinColumn annotation to specify foreign key column in current entity to join with current entity's primary key.

Table
struct Table

Use to specify table name for entity. @Table("table_name") - specifies table name to store entity in, different from default generated. If this annotation not present, table name will be autogenerated as lowercase entity name with conversion of CamelCaseEntityName to camel_case_entity_name.

Transient
struct Transient

@Transient - mark class or field as transient, to not generate HibernateD persistence metadata for it. Use this annotation in cases when field you won't persist will be considered as persistent otherwise.

UniqueKey
struct UniqueKey

@UniqueKey or @UniqueKey() - mark entity property as unique (UNIQUE INDEX will be created for this column, with autogenerated index name) @UniqueKey(indexName) - mark entity property as unique (UNIQUE INDEX will be created for this column, with specified index name) For multiple column unique constraints, use Entity level annotations (TODO).

Variables

UUID_GENERATOR
string UUID_GENERATOR;

standard generator - generates random UUID - for use as @Generator() annotation parameter. Don't forget to import std.uuid

Meta

Authors

Vadim Lopatin