Auto Increment index using findAndModify with Li3 throwing error - lithium

I'm following this post to get an auto increment id instead of using the mongoid but getting error
Method `_connection` not defined or handled in class.
It makes sense because I can't find a function called _connection anywhere. Is it due to an outdated version of Lithium? Am I missing something or how can I accomplish this?
Thanks

That method is public as of 1.0: http://li3.me/docs/api/lithium/1.0.x/lithium/data/Model::connection()

Related

iOS - Method With Success And Error Callbacks Without Initial Parameter

I use success and error callback blocks a lot in method definitions with initial parameters like so:
+(void)doSomethingWithObject:(MyObject*)myObject successCallback:(void (^)(NSArray*))success errorCallback:(void (^)(NSString*))error;
where myObject is the initial parameter. However, I have come across a situation right now where I don't need any parameters. I'm trying to define my method like so:
+(void)getSomeData successCallback:(void (^)(NSArray*))success errorCallback:(void (^)(NSString*))error;
But now Xcode is giving me some syntax complaints. How can I define a method without any initial parameters but also having a success and error callback? Is this impossible or is there just something I don't understand about the correct syntax?
You should edit to
+(void)getSomeDataSuccessCallback:(void (^)(NSArray*))success errorCallback:(void (^)(NSString*))error;

Talend - NullPointer in BigDecimal.add()

I'm having an error on my Job when I do adding of BigDecimal on my tMap.
this is my code.
Var.var1.add(Var.var2).add(Var.var3).add(Var.var4)
all of my variables are BigDecimal.
my error is 'NullPointerException'.
I already checked data on my Database and all have values. I also checked Nullable on my tMap.
Thank You.
This error is happening because you are calling uninitialized variables.
Maybe you are writing this sentence inside the Var box in the tMap?
If not, are you able to output all the Var.varN BigDecimals independently without errors?

Get referring method in VB.net

I'm trying to get the referring method in vb.net.
e.g. I have 1 generic method (sendMail) that handle's emails, any other method can call this. I want sendMail to log an entry to the database when it sends an email. In this log i want the name of method that calls sendMail. I can do it by passing paramaters but I would like to know if sendMail can access the name of the method that calls it.
I found this article that works great in vs
Is it possible to get the referring method in VB.NET?
but unfortunately i'm working in a proprietary application and their IDE and the output I get from StackFrame is 'ExecuteAction at offset 1438 in file:line:column :0:0 '. I think it might be because the StackFrame used in example by Jon works in debug mode not release. (MSDN said something about debug mode but i'm not 100% sure here)
Is there another way of getting the calling method name?
Or am I using StackFrame incorrectly?
Cheers in advance.
dno
public string GetStackTrace()
{
StackTrace st = new StackTrace(true);
StackFrame[] frames = st.GetFrames();
return frames[1].GetMethod().Name.ToString();
}
give it a try:
this method will most likely return the name of its caller, with a few adjustment, you cant tweak it to nest back by increasing the index of the frames array.
good luck

Stubbing a dictionary in Rhino.Mocks

I have a read-only dictionary on a dependency that I'd like to be able to stub with return values, and check that assignments to it have happened.
I was hoping that Rhino.Mocks would create an empty dictionary for me by default, but unfortunately it doesn't. Since it is read-only, I can't create a new dictionary and assign it to that property.
I was hoping to be able to stub it instead. From what I understand, the C# syntax for this would looking something like this:
m.Stub(x => x.myProperty).Return("abc");
So I was hoping that this would work for VB:
m.Stub(sub(x) x.myProperty).Return("abc");
But it doesn't (compiler error). Any ideas on how to accomplish this? I'm open to the Expect/Verify syntax if it can accomplish this...
Using Function will do the trick:
m.Stub(Function(x) x.myProperty).Return("abc")
If you want to verify whether myProperty got called you could use Expect instead of Stub:
m.Expect(Function(x) x.myProperty).Return("abc")
// Some code here
m.VerifyAllExpectations()

Fluent NHibernate RegisterFunction SQLFunctionTemplate usage

I've seen this opportunity reported at least half a dozen times with about as many responses.
My problem is, I've got a MySQL database function defined, we'll call it "my_func(int val) returns int", which works fine if I test directly on the database.
I've also gotten it to work with a direct SQL passthrough my repository implementation, which is okay, but I'd rather route it through Hql, for some god-awful reason...
So... I've got a MySQL5Dialect setup to register the function and I'm having some difficulty parsing through the expected conventions.
My understanding is that I need to prefix the function name with "dbo." at some point during the function registration?
Something like this,
//...
RegisterFunction("my_func", new SQLFunctionTemplate(NHibernateUtil.Int32, "my_func(?1)"));
//...
And then through my repository,
var value = repository.FindByHQL<int>("select my_func(2)").Single();
Where FindByHQL returns an IList.
Any thoughts why this wouldn't work.
I'm running the latest WAMP (2.1e I think).
Enough info? Let me know if I can provide any further details.
Thanks,
Michael
select my_func(2)
is not valid HQL, regardless of whether the function is registered or not.
You can use SQL instead if that's your use case.
Post full exception with stack trace if it's not and this was just a simplified example.