@@ -218,23 +218,13 @@ public Comparable getId (Field idfield, Session s) throws InvocationTargetExcept
218218 for (int i = 0 ; i < f .length ; i ++) {
219219 final Id a = f [i ].getAnnotation (Id .class );
220220 if (a != null ) {
221- if (sa != null ) {
222- id = (Comparable ) f [i ].get (entity );
223- } else {
224- Method z = c .getMethod ("get" + f [i ].getName ().substring (0 , 1 ).toUpperCase () + f [i ].getName ().substring (1 , f [i ].getName ().length ()), new Class <?>[]{Session .class });
225- Object v = z .invoke (entity , new Object []{s });
226- id = (Comparable ) v ;
227- }
221+ final Object entity_ = sa != null ? entity : getEntity (s );
222+ id = (Comparable ) f [i ].get (entity_ );
228223 }
229224 }
230225 } else {
231- if (sa != null ) {
232- id = (Comparable ) idfield .get (entity );
233- } else {
234- Method z = c .getMethod ("get" + idfield .getName ().substring (0 , 1 ).toUpperCase () + idfield .getName ().substring (1 , idfield .getName ().length ()), new Class <?>[]{Session .class });
235- Object v = z .invoke (entity , new Object []{s });
236- id = (Comparable ) v ;
237- }
226+ final Object entity_ = sa != null ? entity : getEntity (s );
227+ id = (Comparable ) idfield .get (entity_ );
238228 }
239229 }
240230 return id ;
@@ -247,15 +237,10 @@ public byte[] getSerializedId (Session s) throws InvocationTargetException, NoSu
247237 }
248238 final Field idf = t .getIdField ();
249239 if (idf != null ) {
250- if (t .isNoTran ()) {
251- final Method z = t .getIdmethod ();
252- id = (Comparable ) z .invoke (entity , null );
253- serializedId = this .external ? sr_ .serialize (idf .getType ().getName (), id ) : sr .serialize (idf .getType ().getName (), id );
254- } else {
255- final Method z = t .getIdmethod_ ();
256- id = (Comparable ) z .invoke (entity , new Object []{s });
257- serializedId = this .external ? sr_ .serialize (idf .getType ().getName (), id ) : sr .serialize (idf .getType ().getName (), id );
258- }
240+ final Object entity_ = getEntity (s );
241+ final Method z = t .getIdmethod ();
242+ id = (Comparable ) z .invoke (entity_ , null );
243+ serializedId = this .external ? sr_ .serialize (idf .getType ().getName (), id ) : sr .serialize (idf .getType ().getName (), id );
259244 }
260245
261246 }
@@ -502,6 +487,14 @@ public Object getExistingEntity() {
502487 return this .entity ;
503488 }
504489
490+ public Object getEntity (Session s ) {
491+ if (t .isNoTran ()) {
492+ return getEntity ();
493+ } else {
494+ return ((EntityContainer ) getEntity ()).getEntity (s );
495+ }
496+ }
497+
505498 public synchronized Object getEntity () {
506499 if (entity ==null ) {
507500 try {
@@ -850,18 +843,13 @@ public DataChunk getIc(IndexDescript ids, Session s) throws Exception {
850843 }
851844
852845 public ValueSet getValueByColumnName (String [] columns , Session s ) throws Exception {
853- final Object o = this .getEntity ();
854- final Class c = o .getClass ();
846+ final Class c = this .getEntity ().getClass ();
855847 final SystemEntity sa = (SystemEntity )c .getAnnotation (SystemEntity .class );
848+ final Object o = sa != null ? this .getEntity () : this .getEntity (s );
856849 final List <Object > res = new ArrayList <>();
857850 for (String name : columns ) {
858- if (sa != null ) {
859- final Method z = c .getMethod ("get" + name .substring (0 , 1 ).toUpperCase () + name .substring (1 , name .length ()), null );
860- res .add (z .invoke (o , null ));
861- } else {
862- final Method z = c .getMethod ("get" + name .substring (0 , 1 ).toUpperCase () + name .substring (1 , name .length ()), new Class <?>[]{Session .class });
863- res .add (z .invoke (o , new Object []{s }));
864- }
851+ final Method z = c .getMethod ("get" + name .substring (0 , 1 ).toUpperCase () + name .substring (1 , name .length ()), null );
852+ res .add (z .invoke (o , null ));
865853 }
866854 return new ValueSet (res .toArray (new Object []{}));
867855 }
0 commit comments