abstract class KeyAsIdProperty extends DefaultProperty
This property class resolves primary and foreign key columns to the correct type reference:
(1) A single-column primary key of a type A is resolved to a type id(A), where id is an overridable
type reference constructor with no default. For example, for a table person with a primary key column
id, a property id: Id[Person] would be emitted if the id(A) type was Id[A].
(2) A foreign key pointing to a single-column primary or unique key (see Column.references) is resolved
to the data type of the referenced property. For example, for a table employees with a foreign key
column person_id, a property personId: Id[Person] would be emitted, using the type Id[Person] of
the referenced property.
For a primary key that is also a foreign key, case (2) prevails, since the primary key is then interpreted as the primary key of another table, just replicated here due to a one-to-one relationship. (This is valid in a few edge cases where the original table can't or shouldn't be manipulated to add more columns.)
Usage Note: For Quill support, your id type should either extend AnyVal (which should suffice in most use cases) or come with an encoder and decoder.
In any case, this property only handles single-column primary and foreign keys. You will have to implement some individual handling if you want to type multi-column keys.
- Alphabetic
- By Inheritance
- KeyAsIdProperty
- DefaultProperty
- Serializable
- Serializable
- Product
- Equals
- Property
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new KeyAsIdProperty(column: Column, model: Model, config: GeneratorConfiguration)
Abstract Value Members
-
abstract
def
id(modelType: TypeReference): TypeReference
Wraps the given model type reference in your Id type.
Wraps the given model type reference in your Id type.
- Attributes
- protected
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate() @throws( ... )
-
val
column: Column
The column to be transformed.
The column to be transformed.
- Definition Classes
- KeyAsIdProperty → DefaultProperty → Property
-
val
config: GeneratorConfiguration
- Definition Classes
- KeyAsIdProperty → DefaultProperty
-
def
dataType: TypeReference
The data type of the property.
The data type of the property. Even though Column already provides a type reference, you can override this definition to provide an updated type based on the property without overriding tpe.
- Definition Classes
- KeyAsIdProperty → Property
-
def
defaultValue: Option[String]
The default value of the property.
The default value of the property.
By default, only nullables are translated to a Scala default value. If you need to translate other default values, please override this method.
- Definition Classes
- DefaultProperty → Property
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
val
model: Model
The model that owns the property.
The model that owns the property.
- Definition Classes
- KeyAsIdProperty → DefaultProperty → Property
-
def
name: String
The name of the property.
The name of the property.
- Definition Classes
- DefaultProperty → Property
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
tpe: TypeReference
The scala type of the property.
The scala type of the property. Sometimes, this type may be a wrapped version of dataType, such as the data type wrapped in an Option for nullable columns.
- Definition Classes
- DefaultProperty → Property
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )