org.scala_libs.jpa

ScalaEntityManager

trait ScalaEntityManager extends AnyRef

This trait represents a Scalafied version of the standard EntityManager in JPA. In particular, queries are more type-safe and the find method returns an Option instead of possibly throwing an exception if the entity isn't found.

If you wish to provide a concrete implementation of this trait, you only need to provide the em method and factory val.

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ScalaEntityManager
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def em: EntityManager

    Returns the current EntityManager instance.

    Returns the current EntityManager instance. This leaves the implementor free to choose how they want to manage instances. For example, the implementor could use a ThreadLocal to allow for a singleton instance of ScalaEntityManager, or they could simply set up a val to hold the current instance.

    Attributes
    protected
  2. abstract val factory: ScalaEMFactory

    This val should hold a reference to the factory that created this instance, so that the proper closeEM method can be called on shutdown.

Concrete Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

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

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

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clear(): Unit

    Clears the persistence context.

    Clears the persistence context. Changes made to any entities that have not been flushed to the database will not be persisted.

  8. def clone(): AnyRef

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

    Closes the EntityManager.

    Closes the EntityManager. Subclasses may override this if they desire different behavior.

  10. def contains(entity: AnyRef): Boolean

    Tests to see if the given entity is attached to the current EntityManager

    Tests to see if the given entity is attached to the current EntityManager

    entity

    The entity to check

    returns

    true if attached, false otherwise

  11. def createNamedQuery[A](queryName: String): ScalaQuery[A]

    Creates a new ScalaQuery[A] using the given named query.

    Creates a new ScalaQuery[A] using the given named query. The results of the named query should be of type A.

    queryName

    The named query to use

    returns

    A new ScalaQuery[A] that uses the given named query

  12. def createNamedQuery[A](queryName: String, params: (String, Any)*): ScalaQuery[A]

    Creates a ScalaQuery representing the given named query with the given parameters set.

    Creates a ScalaQuery representing the given named query with the given parameters set. This can be used if you want to use some of the extended functionality of ScalaQuery, such as pagination or using query hints. An example would be:

    val query = EM.createNamedQuery[Book]("findAllBooks") query.setFirstResult(20).setMaxResults(100)

    queryName

    The name of the query to execute

    params

    Zero or more pairs of (paramName,paramValue)

    returns

    The created ScalaQuery[A]

  13. def createNativeQuery[A](sqlString: String, resultSetMapping: String): ScalaQuery[A]

    Creates a new ScalaQuery[A] using the given native SQL query.

    Creates a new ScalaQuery[A] using the given native SQL query. For more details on using native queries, see http://www.hibernate.org/hib_docs/entitymanager/reference/en/html/query_native.html.

    sqlString

    The query string to use

    resultSetMapping

    The name of the mapping from the result set to entities

    returns

    A new ScalaQuery[A] that uses the given native SQL

  14. def createNativeQuery[A](sqlString: String, clazz: Class[A]): ScalaQuery[A]

    Creates a new ScalaQuery[A] using the given native SQL query.

    Creates a new ScalaQuery[A] using the given native SQL query. For more details on using native queries, see http://www.hibernate.org/hib_docs/entitymanager/reference/en/html/query_native.html.

    sqlString

    The query string to use

    clazz

    The class of the returned entities

    returns

    A new ScalaQuery[A] that uses the given native SQL

  15. def createNativeQuery[A](sqlString: String): ScalaQuery[A]

    Creates a new ScalaQuery[A] using the given native SQL query.

    Creates a new ScalaQuery[A] using the given native SQL query. For more details on using native queries, see http://www.hibernate.org/hib_docs/entitymanager/reference/en/html/query_native.html.

    sqlString

    The query string to use

    returns

    A new ScalaQuery[A] that uses the given native SQL

  16. def createQuery[A](queryString: String): ScalaQuery[A]

    Creates a new ScalaQuery[A] using the given query string.

    Creates a new ScalaQuery[A] using the given query string. The results of the query should be of type A. See http://www.hibernate.org/hib_docs/entitymanager/reference/en/html/queryhql.html for an EJB-QL reference.

    queryString

    The query string (EJBQL)

    returns

    A new ScalaQuery[A] that uses the given query string

  17. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    AnyRef → Any
  19. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  20. def find[A](clazz: Class[A], id: Any): Option[A]

    Attempts to load a given entity based on its ID.

    Attempts to load a given entity based on its ID. Returns an Option, with None indicating that no entity exists with the given ID.

    clazz

    The class of the entity to load

    id

    The ID of the entity to load

    returns

    An Option with the loaded entity (Some) or None to indicate that an entity could not be loaded

  21. def findAll[A](queryName: String, params: (String, Any)*): scala.collection.convert.Wrappers.JListWrapper[A]

    Returns a List[A] of the results of excuting the given query.

    Returns a List[A] of the results of excuting the given query. Named parameters may be provided to refine the query. Using Scala's syntax sugar for Pairs and varargs, an example query might look like:

    EM.findAll[User]("byUsername", "username" -> "fred")

    queryName

    The name of the query to execute

    params

    Zero or more pairs of (paramName,paramValue)

    returns

    A List[A] representing the results of the query

  22. def flush(): Unit

    Forces a flush of the current entity state to the database.

  23. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  24. def getDelegate(): AnyRef

    Returns the underlying provider object for the EntityManager.

    Returns the underlying provider object for the EntityManager. Implementation-specific.

    returns

    The underlying provider

  25. def getFlushMode(): FlushModeType

    Returns the current flush mode for the EntityManager

    Returns the current flush mode for the EntityManager

    See also

    javax.persistence.FlushModeType

  26. def getReference[A](clazz: Class[A], primaryKey: Any): A

    Get an instance, whose state may be lazily fetched.

    Get an instance, whose state may be lazily fetched. An EntityNotFoundException will be thrown when the instance is accessed if no corresponding instance exists in the database. The exception may be thrown when getReference is called.

    clazz

    The class of the instance

    primaryKey

    The primary key of the instance

    returns

    A lazily fetched instance

  27. def getTransaction(): EntityTransaction

    Returns the current EM's transaction.

    Returns the current EM's transaction. Note that this will throw an exception if you're using JTA for transactions.

    returns

    The current transaction

  28. def hashCode(): Int

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

    Definition Classes
    Any
  30. def isOpen(): Boolean

    Returns a boolean indicating whether the EntityManager is open.

    Returns a boolean indicating whether the EntityManager is open.

    returns

    true if the EntityManager is open, false otherwise

  31. def joinTransaction(): Unit

    Joins the EM to the currently open JTA transaction.

    Joins the EM to the currently open JTA transaction. Note that this throws and exception if no JTA transaction exists.

  32. def lock(entity: AnyRef, lockMode: LockModeType): Unit

    Locks the given entity using the given lock mode.

    Locks the given entity using the given lock mode.

    entity

    The entity to lock

    lockMode

    The mode of the lock

    See also

    javax.persistence.LockModeType

  33. def merge[T](entity: T): T

    Merges the given entity and returns the newly merged copy.

    Merges the given entity and returns the newly merged copy.

    entity

    The entity to merge

    returns

    The newly merged copy

  34. def mergeAndFlush[T](entity: T): T

    Handles a merge and flush in a single method.

    Handles a merge and flush in a single method. This is useful if your merge should check for constraint violations, since otherwise the merge won't occur until the transaction closes.

    entity

    The entity to merge.

    returns

    A newly merged copy of the entity. The original entity should be discarded.

  35. final def ne(arg0: AnyRef): Boolean

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

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

    Definition Classes
    AnyRef
  38. def persist(entity: AnyRef): Unit

    Persists the given entity.

    Persists the given entity.

    entity

    The entity to persist

  39. def persistAndFlush(entity: AnyRef): Unit

    Handles a persist and flush in a single method.

    Handles a persist and flush in a single method. This is useful if your persist should check for constraint violations, since otherwise the persist won't occur until the transaction closes.

    entity

    The entity to persist.

  40. def refresh(entity: AnyRef): Unit

    Reloads a given entity's state from the database, effectively discarding any local changes.

    Reloads a given entity's state from the database, effectively discarding any local changes.

    entity

    The entity to refresh

  41. def remove(entity: AnyRef): Unit

    Removes the given entity.

    Removes the given entity.

    entity

    The entity to remove

  42. def removeAndFlush(entity: AnyRef): Unit

    Handles a remove and flush in a single method.

    Handles a remove and flush in a single method. This is useful if your remove should check for constraint violations, since otherwise the remove won't occur until the transaction closes.

    entity

    The entity to remove.

  43. def setFlushMode(flushModeType: FlushModeType): Unit

    Sets the flush mode for the EntityManager.

    Sets the flush mode for the EntityManager.

    flushModeType

    The desired flush mode

    See also

    javax.persistence.FlushModeType

  44. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  45. def toString(): String

    Definition Classes
    AnyRef → Any
  46. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any

Ungrouped