o != arg0 is the same as !(o == (arg0)).
o != arg0 is the same as !(o == (arg0)).
the object to compare against this object for dis-equality.
false if the receiver object is equivalent to the argument; true otherwise.
o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).
o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).
the object to compare against this object for equality.
true if the receiver object is equivalent to the argument; false otherwise.
o == arg0 is the same as o.equals(arg0).
o == arg0 is the same as o.equals(arg0).
the object to compare against this object for equality.
true if the receiver object is equivalent to the argument; false otherwise.
This method is used to cast the receiver object to be of type T0.
This method is used to cast the receiver object to be of type T0.
Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression1.asInstanceOf[String] will throw a ClassCastException at runtime, while the expressionList(1).asInstanceOf[List[String]] will not. In the latter example, because the type argument is erased as
part of compilation it is not possible to check whether the contents of the list are of the requested typed.
the receiver object.
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.
This method creates and returns a copy of the receiver object.
This method creates and returns a copy of the receiver object.
The default implementation of the clone method is platform dependent.
a copy of the receiver object.
Closes the EntityManager.
Closes the EntityManager. Subclasses may override this if they desire different behavior.
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
The entity to check
true if attached, false otherwise
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.
The named query to use
A new ScalaQuery[A] that uses the given named query
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)
The name of the query to execute
Zero or more pairs of (paramName,paramValue)
The created 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.
The query string to use
The name of the mapping from the result set to entities
A new ScalaQuery[A] that uses the given native SQL
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.
The query string to use
The class of the returned entities
A new ScalaQuery[A] that uses the given native SQL
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.
The query string to use
A new ScalaQuery[A] that uses the given native SQL
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. Seehttp://www.hibernate.org/hib_docs/entitymanager/reference/en/html/queryhql.html for an EJB-QL reference.
The query string (EJBQL)
A new ScalaQuery[A] that uses the given query string
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.
This method is used to test whether the argument (arg0) is a reference to the
receiver object (this).
This method is used to test whether the argument (arg0) is a reference to the
receiver object (this).
The eq method implements an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation] on
non-null instances of AnyRef:
* It is reflexive: for any non-null instance x of type AnyRef, x.eq(x) returns true.
* It is symmetric: for any non-null instances x and y of type AnyRef, x.eq(y) returns true if and
only if y.eq(x) returns true.
* It is transitive: for any non-null instances x, y, and z of type AnyRef if x.eq(y) returns true and y.eq(z) returns true, then x.eq(z) returns true.
Additionally, the eq method has three other properties.
* It is consistent: for any non-null instances x and y of type AnyRef, multiple invocations of
x.eq(y) consistently returns true or consistently returns false.
* For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false.
* null.eq(null) returns true.
When overriding the equals or hashCode methods, it is important to ensure that their behavior is
consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2), they
should be equal to each other (o1 == o2) and they should hash to the same value (o1.hashCode == o2.hashCode).
the object to compare against this object for reference equality.
true if the argument is a reference to the receiver object; false otherwise.
This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.
This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.
The default implementations of this method is an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence
relation]:
* It is reflexive: for any instance x of type Any, x.equals(x) should return true.
* It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and
only if y.equals(x) returns true.
* It is transitive: for any instances x, y, and z of type AnyRef if x.equals(y) returns true and
y.equals(z) returns true, then x.equals(z) should return true.
If you override this method, you should verify that your implementation remains an equivalence relation.
Additionally, when overriding this method it is often necessary to override hashCode to ensure that objects
that are "equal" (o1.equals(o2) returns true) hash to the same
scala.Int
(o1.hashCode.equals(o2.hashCode)).
the object to compare against this object for equality.
true if the receiver object is equivalent to the argument; false otherwise.
This val should hold a reference to the factory that created this instance, so that the proper closeEM method can be called on shutdown.
This val should hold a reference to the factory that created this instance, so that the proper closeEM method can be called on shutdown.
This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.
This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.
The details of when and if the finalize method are invoked, as well as the interaction between finalizeand non-local returns and exceptions, are all platform dependent.
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.
The class of the entity to load
The ID of the entity to load
An Option with the loaded entity (Some) or None to indicate that an entity could not be loaded
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")
The name of the query to execute
Zero or more pairs of (paramName,paramValue)
A List[A] representing the results of the query
Forces a flush of the current entity state to the database.
Forces a flush of the current entity state to the database.
Returns a representation that corresponds to the dynamic class of the receiver object.
Returns a representation that corresponds to the dynamic class of the receiver object.
The nature of the representation is platform dependent.
a representation that corresponds to the dynamic class of the receiver object.
Returns the underlying provider object for the EntityManager.
Returns the underlying provider object for the EntityManager. Implementation-specific.
The underlying provider
Returns the current flush mode for the EntityManager
Returns the current flush mode for the EntityManager
javax.persistence.FlushModeType
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.
The class of the instance
The primary key of the instance
A lazily fetched instance
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.
The current transaction
Returns a hash code value for the object.
Returns a hash code value for the object.
The default hashing algorithm is platform dependent.
Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet
not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0.
However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have
identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure
to verify that the behavior is consistent with the equals method.
the hash code value for the object.
This method is used to test whether the dynamic type of the receiver object is T0.
This method is used to test whether the dynamic type of the receiver object is T0.
Note that the test result of the test is modulo Scala's erasure semantics. Therefore the expression1.isInstanceOf[String] will return false, while the expression List(1).isInstanceOf[List[String]] will
return true. In the latter example, because the type argument is erased as part of compilation it is not
possible to check whether the contents of the list are of the requested typed.
true if the receiver object is an instance of erasure of type T0; false otherwise.
Returns a boolean indicating whether the EntityManager is open.
Returns a boolean indicating whether the EntityManager is open.
true if the EntityManager is open, false otherwise
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.
Locks the given entity using the given lock mode.
Locks the given entity using the given lock mode.
The entity to lock
The mode of the lock
javax.persistence.LockModeType
Merges the given entity and returns the newly merged copy.
Merges the given entity and returns the newly merged copy.
The entity to merge
The newly merged copy
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.
The entity to merge.
A newly merged copy of the entity. The original entity should be discarded.
o.ne(arg0) is the same as !(o.eq(arg0)).
o.ne(arg0) is the same as !(o.eq(arg0)).
the object to compare against this object for reference dis-equality.
false if the argument is not a reference to the receiver object; true otherwise.
Wakes up a single thread that is waiting on the receiver object's monitor.
Wakes up a single thread that is waiting on the receiver object's monitor.
Wakes up all threads that are waiting on the receiver object's monitor.
Wakes up all threads that are waiting on the receiver object's monitor.
Persists the given entity.
Persists the given entity.
The entity to persist
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.
The entity to persist.
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.
The entity to refresh
Removes the given entity.
Removes the given entity.
The entity to remove
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.
The entity to remove.
Sets the flush mode for the EntityManager.
Sets the flush mode for the EntityManager.
The desired flush mode
javax.persistence.FlushModeType
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
a string representation of the object.
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
emmethod andfactoryval.authors:
Derek Chen-Becker