44 */
55package org .hibernate .event .spi ;
66
7+ import org .hibernate .Internal ;
78import org .hibernate .LockMode ;
89import org .hibernate .LockOptions ;
910import org .hibernate .Locking ;
@@ -66,32 +67,36 @@ private LoadEvent(
6667 boolean isAssociationFetch ,
6768 EventSource source ,
6869 Boolean readOnly ) {
69-
7070 super ( source );
71+ this .entityId = entityId ;
72+ this .entityClassName = entityClassName ;
73+ this .instanceToLoad = instanceToLoad ;
74+ this .lockOptions = lockOptions ;
75+ this .isAssociationFetch = isAssociationFetch ;
76+ this .readOnly = readOnly ;
77+ validate ();
78+ }
7179
80+ @ Internal
81+ public void validate () {
7282 if ( entityId == null ) {
73- throw new IllegalArgumentException ( "id to load is required for loading " );
83+ throw new IllegalArgumentException ( "Identifier may not be null " );
7484 }
7585
76- if ( lockOptions .getLockMode () == LockMode .WRITE ) {
77- throw new IllegalArgumentException ("Invalid lock mode for loading" );
86+ final var lockMode = lockOptions .getLockMode ();
87+ if ( lockMode == LockMode .WRITE ) {
88+ throw new IllegalArgumentException ( "Invalid lock mode: " + LockMode .WRITE );
7889 }
79- else if ( lockOptions . getLockMode () == null ) {
90+ else if ( lockMode == null ) {
8091 lockOptions .setLockMode ( LockMode .NONE );
8192 }
82-
83- this .entityId = entityId ;
84- this .entityClassName = entityClassName ;
85- this .instanceToLoad = instanceToLoad ;
86- this .lockOptions = lockOptions ;
87- this .isAssociationFetch = isAssociationFetch ;
88- this .readOnly = readOnly ;
8993 }
9094
9195 public Object getEntityId () {
9296 return entityId ;
9397 }
9498
99+ @ Internal
95100 public void setEntityId (Object entityId ) {
96101 this .entityId = entityId ;
97102 }
@@ -100,6 +105,7 @@ public String getEntityClassName() {
100105 return entityClassName ;
101106 }
102107
108+ @ Internal
103109 public void setEntityClassName (String entityClassName ) {
104110 this .entityClassName = entityClassName ;
105111 }
@@ -108,6 +114,7 @@ public boolean isAssociationFetch() {
108114 return isAssociationFetch ;
109115 }
110116
117+ @ Internal
111118 public void setAssociationFetch (boolean associationFetch ) {
112119 isAssociationFetch = associationFetch ;
113120 }
@@ -116,6 +123,7 @@ public Object getInstanceToLoad() {
116123 return instanceToLoad ;
117124 }
118125
126+ @ Internal
119127 public void setInstanceToLoad (Object instanceToLoad ) {
120128 this .instanceToLoad = instanceToLoad ;
121129 }
@@ -124,6 +132,7 @@ public LockOptions getLockOptions() {
124132 return lockOptions ;
125133 }
126134
135+ @ Internal
127136 public void setLockOptions (LockOptions lockOptions ) {
128137 this .lockOptions = lockOptions ;
129138 }
@@ -140,12 +149,11 @@ public Boolean getReadOnly() {
140149 return readOnly ;
141150 }
142151
152+ @ Internal
143153 public void setReadOnly (Boolean readOnly ) {
144154 this .readOnly = readOnly ;
145155 }
146156
147-
148-
149157 /**
150158 * @deprecated Use {@linkplain #getLockOptions()} instead.
151159 */
0 commit comments