When retrieving the list of "master" objects, Backand Fails to retrieve "slave" objects - backand

When retrieving the list of "master" objects, Backand Fails to retrieve "slave" objects
app
springnutjs
When retrieving the list of "master" objects (the ones with the "collection, via" field),
Backand Fails to retrieve "slave" (the ones with the "object" field) objects
even if it does work retrieving the "master" objects when retrieving the list of all "slave" objects

In order to get collections ("slave") you need to use query parameter: deep=true. When calling a list of objects there is no deep at all, but when getting a single master with deep=true you will get all the children ("slaves").
For example, when you run /1/objects/master/1?deep=true you will get all slaves.
Running /1/objects/master?deep=true no slaved but only related objects.

Related

Entity joining in xml

I have run into a little roadblock in regards to joining mantle entities. I would like to have a single depicting fields from two mantle entities, but am unsuccessful in joining them. Specifically, I have linked a list of party relationships (as contacts) to a single partyId (vendor), with the goal to make a vendor contacts page. However I am unable to link that form-list with the PartyContactMech and ContactMech entities (in order to display email and phone number in the same form-list). More generally, my question is how can one map lists to each other the same way one can map a list to a single object (using entity-find-one and value-field does not work when tried with entity-find)?
There is no need to make a view-entity (join entities) to do that. Simply do a query on the PartyRelationship entity in the main 'actions' part of your screen specifying the toParty (vendor). Then in your Form-List, use 'row-actions' to query the PartyContactMech and so on for each fromPartyId (contact) entry that the previous query returned. Also have a look at the PartyViewEntities file in Mantle USL. There are some helpful view-enties already defined for you there such as PartyToAndRelationship, PartyFromAndRelationship etc. Also note that entity-find-one returns a single "map" (value-field) as it queries on the PK. Whereas entity-find returns a list of maps (list). They are separate query types. If I understand your question correctly.

Backand deep querying

I want to know if it is possible to retrieve and the collection of objects that an object holds in Backand.
For example - you have an object 'Trip' which has a one-to-many relationship with 'Destination' as a trip can have many destinations. The attribute 'destination' in object 'Trip' is a collection.
Is it possible, when querying for a 'Trip' object, that I am able to receive the associated 'Destination' objects that the 'Trip' object has a collection of ?
While getting the parent object (/1/objects/Trip) there is no way to get information on the collection object (Destination), so you need to create a query for it:
SELECT trip FROM Destination
WHERE trip IS NOT NULL
group by trip
The query will return all the Trip id(s), which you can loop and make a specific API request for each Trip. To get the collection of the Destinations use deep=true, like this:
/1/objects/Trip/1?deep=true
Depend on you client UI, you can do the code above and make it a Lazy load using Promise. You could create an on-demand action and run the loop on the server and return a JSON with all the data at once.

GemFire value change without refreshing all values

I m using (String, Arraylist of String) as the key value pair in gemfire caching.Is there any method to just add or delete a particular value from the value list without getting the entire list and add/delete and publishing the list again?!
You can create wrapper object to keep list. This wrapper object can implement delta interface. Using this you can add/delete field from list. See if this helps.
GemFire serializes the value when storing, and has various complex configurations to control the type and level of serialization.
Therefore, when you're updating a value in the value, what's happening is that the serialized value is being streamed to the client and then you're changing it and then re-serializing the changed value and streaming it to the server which is then storing it.
If you want to just update a value in the ArrayList on the server side itself, then you have to create a server-side listener and add that class to the server's classpath so you can manage the serialization/deserialization more finely.
Alternatively, you probably need to change your data model so that the ArrayList value is more like a Map, and is flattened to a secondary region colocated with the primary region, etc.

Including a list of related entities in the Elasticsearch index

Using the elasticsearch module, is it possible to somehow index the results of a related collection, which is lazy-loaded?
I have a model type Book, which has many Authors, which are lazy loaded
If I annotate the list of authors as #ElasticSearchEmbedded, I get the following exception:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: models.Book.authors, no session or session was closed
If I mark it as ignored, of course everything goes fine. Is there a way to at least get the names of the authors in the Book index?

NHibernate: If two calls are made to CreateCriteria, which list is Get<T> going to retrieve the object from?

Under one UnitOfWork (session) I may call CreateCriteria twice. My first call is to populate a grid for data editing. Let's say the data has been edited and flushed (saved) to the database and the grid is still open. After the data is edited, I may call CreateCriteria a second time to retrieve a list of objects that are validated and found in error.
Lets say ObjectA was retrieved by both calls to session.CreateCriteria. It was edited in the grid but found in error within the second list.
The first question would be: Considering first level cache, is ObjectA--that was retrieved from the second call to CreateCriteri--represent the one retrieved from the first call? or, better yet, did NHibernate "detect and reuse" ObjectA from the first call assuming the keys did not change?
To my final point in question: I want to edit ObjectA which was found in error, and let's say it was brought up in a ListBox. Therefore, I want to highlight that object, call session.Get()(key) in order to retrieve it from cache, then bring up a change form to change ObjectA's properties. Which object am I changing? The one from the first call to CreateCriteria or the second call? Are they the same?
Thank you in advance.
Second level cache
Take a look at http://ayende.com/Blog/archive/2006/07/24/DeepDivingIntoNHibernateTheSecondLevelCache.aspx and http://www.javalobby.org/java/forums/t48846.html
From the former:
The second level cache does not hold
entities, but collections of values
So, with caching setup properly, NHibernate will be able to recreate your object without having to get the actual values from the database. In other words, the object will be created the same as when it wasn't in cache, except that since the values are cached, NHibernate won't actually query the database since it already knows what's in there.
I'm not quite sure what you mean by "validation" and "found in error". Are you validating before insert? Typically my entities are validated before the insert/update and won't actually be inserted/updated if invalid.
Validation aside, what I think you're asking is that if you:
save something
do a flush
retrieve an item (from a new session) with the same key as the one saved in step 1
will you be retrieving the same reference to the object you saved in step 1(?). And the answer is no since NHibernate does not cache the OBJECT but rather the values so it can create a new entity populated with the cached values (instead of actually performing a DB query).
However, does that really matter? If you overload Equals such that equality of 2 entities are based on their ID, then finding the same (not reference equal, but same) item in a grid (or a hash of any kind) should be a snap.
First level cache
I didn't realize you were talking about 1st level cache. 1st level cache works as an identity map and does cache the instance of the object. Therefore, if you do 2 selects from the db based on the same ID, you will retrieve the same instance of the object.