Home > other >  MyBatis - Plus the LambdaQueryWrapper was introduced into entity method reference for how to impleme
MyBatis - Plus the LambdaQueryWrapper was introduced into entity method reference for how to impleme

Time:09-26



Business code would only write four years of development, the distributed high concurrency also can't be a programmer? ->>


MyBatis - Plus the LambdaQueryWrapper was introduced into entity method reference for how to implement the property name?

Such as down code:



I'm curious inside it is how to realize the retrieve productKey the property name,

CodePudding user response:


Not say directly on the code
//this is MybatisPlus the underlying implementation, I just took it out
Public class MybatisPlusApplicationTests {

@ Test
Public void test () {
//for a class of MybatisPlus SerializedLambda object can see
SerializedLambda SerializedLambda=getSerializedLambda (Banner: : getBannerName);
System. The out. Println (serializedLambda getImplMethodName ());//output is: getBannerName, then do a simple string interception can obtain bannerName attribute name
}

Public static SerializedLambda getSerializedLambda (SFunction Lambda) {
SerializedLambda SerializedLambda=null;
Try {
ObjectInputStream objIn=new ObjectInputStream (new ByteArrayInputStream (serialize (lambda))) {
Protected Class<?> ResolveClass (ObjectStreamClass ObjectStreamClass) throws IOException, ClassNotFoundException {
Class<?> Clazz=super. ResolveClass (objectStreamClass);
Return clazz==Java. Lang. Invoke. SerializedLambda. Class? SerializedLambda. Class: clazz;
}
};
SerializedLambda=(serializedLambda) objIn. ReadObject ();
{} the catch (Exception x)
}
Return serializedLambda;
}

Public static byte [] serialize (Object Object) {
If (object==null) {
return null;
} else {
ByteArrayOutputStream baos=new ByteArrayOutputStream (1024);
Try {
The ObjectOutputStream oos=new ObjectOutputStream (baos);
Oos. WriteObject (object);
Oos. The flush ();
{} the catch (IOException var3)
Throw new IllegalArgumentException (" Failed to serialize the object of the type: "+ object. The getClass (), var3);
}

Return baos. ToByteArray ();
}
}
}

CodePudding user response:


All converted to lowercase, and then classload reflection

CodePudding user response:


Inside there is a static object for all the entity class mapping relation

CodePudding user response:


Product: : getProductKey the lambda expressions is a Method of reference types are
Java. Lang. Reflect the Method
Then inside it can make the name by reflection, such as mMethod. The getName (), and then obtains the correlation properties and the field name,

CodePudding user response:


Simple said is the callback interface

CodePudding user response:

The expressions of the C + +, Java JVM encapsulated, the same principle as a C
  • Related