Spring Data index autocreate - spring-data-mongodb

Is it possible for Spring Data Mongo to create indexes automatically based on Repository methods? Maybe there is some third-party plugin or annotation? Maybe there is an API (provides requested fields) that can help me with this task?

In annotation #EnableMongoRepositories you need set property createIndexesForQueryMethods((doc)) to true and enable automatic index creation(doc).

Related

ITfoxtec SAML 2.0: Dynamic configuration

I would like to know if it's possible to configure the library during runtime (Saml2Configuration). We want to have the ability to set the configuration options and get them from DB.
Thank you
Yes no problem. You can populate the Saml2Configuration at runtime on load or in the controller just before setting the Saml2Configuration object in the constructor.
Here an example from FoxIDs https://github.com/ITfoxtec/FoxIDs/blob/master/src/FoxIDs/Logic/Saml/SamlAuthnDownLogic.cs#L70

Include custom attributes using Spring Cloud Stream (StreamBridge)

This document describes how to include custom attributes into PubSub messages.
https://cloud.google.com/pubsub/docs/samples/pubsub-publish-custom-attributes
Is this possible using the newer Spring Cloud Stream functional APIs?
streamBridge.send("myEvent-out-0", event)
I am currently publishing as per above. The second param is just of type "Object", so no way to differentiate custom v regular attributes.
Thanks
You can publish Spring Message and specify your attributes as headers
streamBridge.send("myEvent-out-0", MessageBuilder
.withPayload(event).setHeader("fooKey", "fooValue").setHeader("barKey", "barValue").build());

What are the differences between mobiledata and cloudant services?

hello I am analyzing these two services to use In my app, and I could not find some doc about the difference between these two services. I know that mobiledata extends the cloudant, but what are the pro and cons? In my case I need to have more control above the data, for example create views (I could not create In mobiledata service) etc
So, do you know what the main divergences between these two services? When to use mobile data or cloudant?
Thanks
There are three ways to use Cloudant on Bluemix from an iOS application:
Use Cloudant directly by adding it as a service to your application.
Use MobileFirst for iOS, the Data part specifically (currently beta).
Use the Mobile Data cross-platform SDK.
(1) and (2) allow you to use views within Cloudant by adding them
via either the Cloudant dashboard or by using the Cloudant HTTP API.
(3) is a service which uses Cloudant in the background, but provides
no direct access to your data using the Cloudant HTTP API; you're
limited to the services exposed by the SDK. Therefore you can't use
many Cloudant features like views or Cloudant Query. Think of
Cloudant more as an implementation detail here, rather than an
exposed component as it is for (1) and (2).
Therefore, (1) or (2) is probably more suitable for your needs as
you mention wanting to use views.
Backend of mobile data service of bluemix is cloudant.For details please refer below link on getting started:
https://www.ibm.com/developerworks/cloud/library/cl-rapiddev-app/
http://www.techrepublic.com/blog/the-enterprise-cloud/managing-your-databases-in-the-cloud-how-cloudant-does-it/
https://www.ibm.com/developerworks/cloud/library/cl-rapiddev-app/
P.S- Cloudant is no-sql(create view wont be supported) DBAAS
For details on no-sql,please follow below link:
http://www.zdnet.com/article/what-is-nosql-and-why-do-you-need-it/
Cloudant is the IBM bluemix mobile data backend. And yes you can build sorted secondary key:value indexes, called "views" using JavaScript MapReduce functions.
Here is an example :
map: function(doc){
if (doc.rep){ emit({"rep": doc.rep}, doc.amount); }
}
reduce: _sum
For more details you can refer these links :
http://examples.cloudant.com/sales/_design/sales/index.html
http://examples.cloudant.com/sales/_design/sales/index.html#basic
http://examples.cloudant.com/whatwouldbiebersay/_design/whatwouldbiebersay/index.html
For mobiledata cloudant is acting behind the scenes. Cloudant is an open source
non-relational, distributed database service of the same name that requires zero-configuration.
Cloudant is based on the Apache-backed CouchDB project and the open source BigCouch
project.
Please follow below link for more details:
https://cloudant.com/cloudant-ibm-bluemix-tutorials-and-demos/

Grails: updating hibernate after externally loading data

I have a grails application. I'd like to load data into the underlying database with something external to grails, perl, specifically. I know I have to update the hibernate sequence after external data loading, otherwise on the next create object in grails, hibernate throws an exception; but is there anything else I need to update? Do I have to clear the hibernate cache, for instance? This would seem to be a very common issue, but there's no discussion of it in the grails docs. Thanks.
Found this
http://grails.1312388.n4.nabble.com/Accessing-the-2nd-level-cache-to-allow-it-to-be-cleared-via-a-controller-or-service-td1390985.html
Hibernate has APIs for this. You can get the query cache via sessionFactory.getQueryCache() and clear it using
sessionFactory.queryCache.clear()
You can access a cache for a domain classes using its full class name, e.g.
def cache = sessionFactory.getSecondLevelCacheRegion('com.foo.bar.Book')
and clear it via
sessionFactory.getSecondLevelCacheRegion('com.foo.bar.Book').clear()
You can also call evict() on the sessionFactory for an entire class
sessionFactory.evict(com.foo.bar.Book)
or for an individual instance
sessionFactory.evict(com.foo.bar.Book, 42)

Do I need to re-cache my object after I updated it in the memcache of Google AppEngine?

I am currently using Google AppEngine(Java) to build a web site.
I created a bean to be cached in the memcache, when I retrieved it from the memecache and called some methods on it to update its status, do I need to re-cache it into memcache?
I guess that memcache used its reference, so I should not need to do it. But things turn out that I am not correct. I am a little confused.
Yes you need to re-cache a bean, if you want to update it in the memcache.http://code.google.com/appengine/docs/java/memcache/overview.html

Resources