Bind global parameter, available in all mybatis mappers - mybatis

Is there any way to bind global parameter, which will be available for all mappers?
I'm trying to use parameter which I set with:
sqlSessionFactory.getConfiguration().getVariables().setProperty("1param", "1value");
but when I invoke specific metod with construction
<if test='1param == "1value"'>
I'm getting exception that parameter is not available.

Related

How to keep default constructor after declared another in java?

I want to access default constructor from a class, (after I create another constructors with any parameters), without declared him!
How can I access default constructor without declared him?

Prevent object creation if some conditions are violated

In a script I want to create an object of a class only if all the constructor inputs meet some conditions. All the checks are embedded in the constructor itself. Problem is when:
myObj = myClass(input1,input2,...);
is triggered in the script. The object, even when an input doesn't meet the relative condition, is still created eventually with all empty properties.
Inserting the following code within the constructor:
if nargout == 0
clear obj;
end
prevents the creation of the object, but only when the output is assigned to the ans variable. Otherwise, I get an error.
Is there a way to obtain something like that without adding some code directly into the script (like using try)?
If the constructor throws an error, no object will be created. Use error. You can put a try/catch block around the constructor call if you like.
There is no way AFAIK to have the constructor return normally but produce no object. What would be assigned to its output?

Specification builder doesn't recognize transient properties

I'm trying to implement specification in one of my use cases.
As u can see in the function dateValueBetween, I'm trying to get from the root the transient property valueDate. But when calling this service with real data it give the error downside.
My original problem was how to call the builder.between method but the value I have is a String value and need to be parsed.
but it seems that the first argument need to be a property of the table and not a function.
How can I achieve my goal?

Passing complex object as parameter to sub-stack

I want to pass the output of a custom resource, which is an array of objects, as parameter to a sub-stack. An example of what I want to pass as parameter to the child stack is :
[
{"Role":"Role1","IdentifierType":"Prefix","Identifiers":"Bucket1"}
{"Role":"Role2","IdentifierType":"Prefix","Identifiers":"Bucket2"}
]
How do I pass this to the sub-stack? I tried declaring the parameter in the child stack as String, and later as CommaDelimitedList. Both the times, the stack gave an error: "Value of property Parameters must be an object with String (or simple type) properties"
As I know until now, there is not way to pass complex objects as a result of of stack execution. Like the message say, the outputs need to be string or single types (integer and boolean in case of cloudformation).
Without more information is hard to help you with alternatives, but let's assume that your Custom Resource is based on lambda. And let's assume that you have control about the code of your Custom Resource. If this is the case you can:
Send the resource identification of your custom resource as a parameter for your nested stack;
Inside nested stack, invoke the lambda function again with the resourceId as a parameter;
Change the lambda code to check for a new parameter for the resourceId (inside the ResourceParameters, not inside the Common Resource Id sent by CloudFormation).
If the parameter is not empty (or not a defined value passed on the first invocation) respond with the old values (you must have a way to keep this values in some place or check then in runtime.);
Change the lambda code to do not take action in the update/deletion is case of invocation by the nested stack (with the resourceId parameter).
Again, is hard to think in alternatives without more info about your specific problem. But use this response as a food for thought.

YUI autocomplete plugin is undefined

My vary simple code: var ac = Y.Plugin.AutoComplete("searchInput", "results");
ERROR: Uncaught TypeError: Object # has no method 'AutoComplete'
do I need to include some specific js file or...?
This probably means you're not calling it the right way. Although I didn't use it before, the documentation says it only takes one parameter, not two strings. See AutoComplete API :
init ( config ) Base
Inherited from BaseCore but overwritten in base/js/Base.js:191
Init lifecycle method, invoked during construction. Fires the init
event prior to setting up attributes and invoking initializers for the
class hierarchy. Parameters:
config Object
Object with configuration property name/value pairs
Returns: Base: A reference to this object
So you should try to create a config object and pass it as parameter.
Alexis