sorm

Instance

class Instance extends Initialization with Api

The instance of SORM

Linear Supertypes
Api, Initialization, StrictLogging, Logging, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Instance
  2. Api
  3. Initialization
  4. StrictLogging
  5. Logging
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Instance(entities: Traversable[Entity], url: String, user: String = "", password: String = "", poolSize: Int = 1, initMode: InitMode = InitMode.Create, timeout: Int = 30)

    entities

    A list of entity settings describing the entities to be registered with this instance

    url

    A url of database to connect to. For instance, to connect to a database test on MySQL server running on your computer it will be: jdbc:mysql://localhost/test

    user

    A username used for connection

    password

    A password used for connection

    poolSize

    A size of connection pool. Determines how many connections to the db will be kept at max. Useful for multithreaded databases.

    initMode

    An initialization mode for this instance

    timeout

    Amount of seconds the underlying connections may remain idle. Determines how often the "keepalive" queries will be emitted.

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. def close(): Unit

    Free all the underlying resources.

    Free all the underlying resources. Useful in multi-instance tests

    Definition Classes
    Api
  7. val connector: Connector

    Attributes
    protected
    Definition Classes
    Initialization
  8. def delete[T <: AnyRef](value: T)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): Unit

    Delete a persisted entity

    Delete a persisted entity

    T

    The entity

    value

    The entity

    Definition Classes
    Api
  9. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  11. def fetchById[T <: AnyRef](id: Long)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): T with Persisted

    Fetch an existing entity by id.

    Fetch an existing entity by id. Will throw an exception if the entity doesn't exist.

    id

    The id

    returns

    An entity instance with a sorm.Persisted trait mixed in

    Definition Classes
    Api
  12. def fetchWithSql[T <: AnyRef](template: String, values: Any*)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): Seq[T with Persisted]

    Select entities using a plain sql statement.

    Select entities using a plain sql statement. This function allows to execute custom queries which in certain situations may be better optimized than the ones generated by SORM.

    Please note that the statement must select only the id column.

    Example:

    Db.fetchWithSql[Artist]("SELECT id FROM artist WHERE name=? || name=?", "Beatles", "The Beatles")
    T

    The type of entities to fetch

    template

    The sql with question-symbols used as placeholders for values

    values

    The values

    returns

    Matching entities of type T

    Definition Classes
    Api
  13. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  15. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  16. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  17. val logger: Logger

    Attributes
    protected
    Definition Classes
    StrictLogging → Logging
  18. val mappings: Map[Reflection, EntityMapping]

    Attributes
    protected
    Definition Classes
    Initialization
  19. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  20. final def notify(): Unit

    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  22. lazy val now: () ⇒ DateTime

    Current DateTime at DB server.

    Current DateTime at DB server. Effectively fetches the date only once to calculate the deviation.

    Definition Classes
    Api
  23. def query[T <: AnyRef](implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): Querier[T]

    Return the sorm.Querier object for performing a read-query on a specified entity type.

    Return the sorm.Querier object for performing a read-query on a specified entity type.

    T

    The entity type

    returns

    The accessor object. An abstraction over all kinds of supported SELECT-queries.

    Definition Classes
    Api
  24. def save[T <: AnyRef](value: T)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): T with Persisted

    Save the entity.

    Save the entity. An Abstraction over INSERT and UPDATE-queries. Which one to perform will be decided based on whether the sorm.Persisted trait is mixed in the value you provide.

    value

    The value to save

    returns

    The saved entity instance with a sorm.Persisted trait mixed in

    Definition Classes
    Api
  25. def saveByUniqueKeys[T <: AnyRef](value: T)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): T with Persisted

    Saves the entity by overwriting the existing one if one with the matching unique keys exists and creating a new one otherwise.

    Saves the entity by overwriting the existing one if one with the matching unique keys exists and creating a new one otherwise. Executing simply sorm.Instance.Api#save in a situation of unique keys clash would have thrown an exception. Beware that in case when not all unique keys are matched this method will still throw an exception.

    value

    The value to save

    returns

    The saved entity instance with a sorm.Persisted trait mixed in

    Definition Classes
    Api
  26. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  27. def toString(): String

    Definition Classes
    AnyRef → Any
  28. def transaction[T](t: ⇒ T): T

    Perform several db-requests in a single transaction.

    Perform several db-requests in a single transaction. For most dbs this provides guarantees that nothing will be changed in between the db-requests in multithreaded applications and that it will roll-back in case of any failure.

    All db-requests which should be executed as part of this transaction must be run on the same thread this method gets called on.

    Use transactions with care because for the time the transaction is being executed the involved tables are supposed to get locked, putting all the requests to them from other threads in a queue until the current transaction finishes. The best practice is to make transactions as short as possible and to perform any calculations prior to entering transaction.

    T

    The result of the closure

    t

    The closure wrapping the actions performed in a single transaction.

    returns

    The result of the last statement of the passed in closure

    Definition Classes
    Api
  29. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def nowMillis(): Long

    Current time at DB server in milliseconds.

    Current time at DB server in milliseconds. Effectively fetches the date only once to calculate the deviation.

    Definition Classes
    Api
    Annotations
    @deprecated
    Deprecated

    now().getMillis should be used instead

Inherited from Api

Inherited from Initialization

Inherited from StrictLogging

Inherited from Logging

Inherited from AnyRef

Inherited from Any

Ungrouped