@@ -44,11 +44,11 @@ import kotlin.reflect.jvm.jvmErasure
4444 *
4545 * ### Creating Entity Objects
4646 *
47- * As everyone knows, interfaces cannot be instantiated, so Ktorm provides [Entity.create] functions for us to
48- * create entity objects. Those functions generate implementations for entity interfaces via JDK dynamic proxy
47+ * As everyone knows, interfaces cannot be instantiated, so Ktorm provides a [Entity.create] function for us to
48+ * create entity objects. This function generate implementations for entity interfaces via JDK dynamic proxy
4949 * and create their instances.
5050 *
51- * If you don't like creating objects by [Entity.create] functions , Ktorm also provides an abstract factory class
51+ * In case you don't like creating objects by [Entity.create], Ktorm also provides an abstract factory class
5252 * [Entity.Factory]. This class overloads the `invoke` operator of Kotlin, so we just need to add a companion
5353 * object to our entity class extending from [Entity.Factory], then entity objects can be created just like there
5454 * is a constructor: `val department = Department()`.
@@ -71,7 +71,7 @@ import kotlin.reflect.jvm.jvmErasure
7171 * - For [Boolean] type, the default value is `false`.
7272 * - For [Char] type, the default value is `\u0000`.
7373 * - For number types (such as [Int], [Long], [Double], etc), the default value is zero.
74- * - For the [String] type, the default value is the empty string.
74+ * - For [String] type, the default value is an empty string.
7575 * - For entity types, the default value is a new-created entity object which is empty.
7676 * - For enum types, the default value is the first value of the enum, whose ordinal is 0.
7777 * - For array types, the default value is a new-created empty array.
@@ -150,15 +150,14 @@ public interface Entity<E : Entity<E>> : Serializable {
150150 * Using this function, we need to note that:
151151 *
152152 * 1. This function requires a primary key specified in the table object via [Table.primaryKey],
153- * otherwise Ktorm doesn’t know how to identify entity objects, then throws an exception.
153+ * otherwise Ktorm doesn’t know how to identify entity objects and will throw an exception.
154154 *
155- * 2. The entity object calling this function must **be associated with a table** first. In Ktorm’s implementation,
156- * every entity object holds a reference `fromTable`, that means this object is associated with the table or was
157- * obtained from it. For entity objects obtained by sequence APIs, their `fromTable` references point to the current
158- * table object they are obtained from. But for entity objects created by [Entity.create] or [Entity.Factory], their
159- * `fromTable` references are `null` initially, so we can not call [flushChanges] on them. But once we use them with
160- * [add] or [update] function of entity sequences, Ktorm will modify their `fromTable` to the current table object,
161- * then we can call [flushChanges] on them afterwards.
155+ * 2. The entity object calling this function must be ATTACHED to the database first. In Ktorm’s implementation,
156+ * every entity object holds a reference `fromDatabase`. For entity objects obtained by sequence APIs, their
157+ * `fromDatabase` references point to the database they are obtained from. For entity objects created by
158+ * [Entity.create] or [Entity.Factory], their `fromDatabase` references are `null` initially, so we can not call
159+ * [flushChanges] on them. But once we use them with [add] or [update] function, `fromDatabase` will be modified
160+ * to the current database, so we will be able to call [flushChanges] on them afterwards.
162161 *
163162 * @see add
164163 * @see update
@@ -182,7 +181,7 @@ public interface Entity<E : Entity<E>> : Serializable {
182181 * 1. The function requires a primary key specified in the table object via [Table.primaryKey],
183182 * otherwise, Ktorm doesn’t know how to identify entity objects.
184183 *
185- * 2. The entity object calling this function must ** be associated with a table** first.
184+ * 2. The entity object calling this function must be ATTACHED to the database first.
186185 *
187186 * @see add
188187 * @see update
@@ -209,6 +208,27 @@ public interface Entity<E : Entity<E>> : Serializable {
209208 */
210209 public fun copy (): E
211210
211+ /* *
212+ * Indicate whether some other object is "equal to" this entity.
213+ * Two entities are equal only if they have the same [entityClass] and [properties].
214+ *
215+ * @since 3.4.0
216+ */
217+ public override fun equals (other : Any? ): Boolean
218+
219+ /* *
220+ * Return a hash code value for this entity.
221+ *
222+ * @since 3.4.0
223+ */
224+ public override fun hashCode (): Int
225+
226+ /* *
227+ * Return a string representation of this table.
228+ * The format is like `Employee{id=1, name=Eric, job=contributor, hireDate=2021-05-05, salary=50}`.
229+ */
230+ public override fun toString (): String
231+
212232 /* *
213233 * Companion object provides functions to create entity instances.
214234 */
0 commit comments