سؤال

I do have an entity like below and which does have an EmbedMap [The entity details are below]

@Data
@Entity
public class Data
{
    @Id long id;
    @EmbedMap private Map<String, SubData> subData = Maps.newHashMap();
}

@Data
public class SubData
{
    private String data1;
    private String data2;
}

lets say the datastore entity has below data stored:

Column : Data

id : 1

subData.KEY1.data1 : data1

subData.KEY1.data2 : data2

subData.KEY2.data3 : data3

subData.KEY2.data4 : data4

so, I would like to fetch only Data with first 3 coulmns data. Meaning the id and the subData map with only KEY1 data using Objectify?

is there a possibility?

Apologies - Could not format the data in the proper table format.

هل كانت مفيدة؟

المحلول

You can either retrieve the entire entity, or only the required properties using a projection query. It will not work in your case, though, as you store all data in a single property.

Instead of storing a Map in one property, you can store each value in its own property, using its key as a property kind. Then you can create a projection query that fetches only the properties that you need. I am pretty certain that you can restructure your data model this way.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top