Summary: GigaSpaces JavaSpaces API Plain Old Java Object support - the POJO. This advanced section deals with the annotations and gs.xml mapping file, ways for troubleshooting, considerations, UID generation and usage as well as frequently used code snippets.

POJO Annotations and XML Space Mapping (gs.xml) File Elements

GigaSpaces supports class and field-level annotations. You can define common behavior for all class instances, and specific behavior for class fields.

The Java Annotations is supported since JVM 1.5. For JVM 1.4, you will need to use the XML space mapping (gs.xml) file.
Annotations

Class Level Annotation – @SpaceClass

Annotation Element Name Type Description Default Value
replicate boolean When running in partial replication mode, a true value for this field replicates all objects of this type to a target space or spaces. true
persist boolean When a space is defined as persistent, a true value for this annotation persists objects of this type.

For more details, refer to the Persistency section.

true
fifo boolean To enable FIFO-based notifications and take operations, this annotation should be true.

For more details, refer to the FIFO operations section.

false
includeProperties String IncludeProperties.IMPLICIT takes into account all POJO fields – even if a get method is not declared with a @SpaceProperties annotation, it is taken into account as a space field.

IncludeProperties.EXPILICT takes into account only the get methods which are declared with a @SpaceProperties annotation.
IMPLICIT
inheritIndexes boolean Whether to use the class indexes list only, or to also include the super class indexes.
If the class does not define indexes, superclass indexes are used.
Options:
  • false – class indexes only.
  • true – class indexes and superclass indexes.
true

Field Level Annotation – @SpaceProperty

Element Type Description Default Value
index Enum of com.gigaspaces.annotation.pojo.SpaceProperty.IndexType Defines if this field data is indexed. Querying indexed fields speeds up read and take operations. Possible values of NONE and BASIC. NONE
nullValue String Specifies that a value be treated as null.  

example:

@SpaceProperty(nullValue="-1" , index=IndexType.BASIC}
public int getEmployeeID()
{
	return employeeID;
}

where -1 functions as a null value.

It is highly recommended to index fields used for matching/query. Without the proper indexing (regular or extended ), the read/readMultiple/take/takeMultiple operations response time might be affected.

Field Level Decoration – @SpaceId

The space mapping file element name for @SpaceId is id (see below).

Defines whether this field value is used when generating the Object UID. The field value should be unique – i.e., no multiple objects with the same value should be written into the space (each object should have a different field value). When writing an object into the space with an existing id field value, an EntryAlreadyInSpaceException is thrown. The Object UID is created, based on the id field value.

The @SpaceID annotation cannot be used with multiple fields. You may specify only one field to be used as the @SpaceId field.

If autoGenerate is declared as false, the field is indexed automatically. If autoGenerate is declared as true, the field isn't indexed.
If autoGenerate is true, the field must be of the type java.lang.String.

Element Type Description Default Value
autoGenerate boolean Specifies if the object UID is generated automatically by the space when written into the space. If false, the field is indexed automatically, and if true, the field isn't indexed false

For more details, see the POJO UID Generation and Usage Scenarios section.

Field Level Decoration – @SpaceVersion

This specifies a get method for holding the version ID. This field should be an int data type.

The @SpaceVersion must be an int data type.

Field Level Decoration - @SpacePersist

This specifies a getter method for holding the persistency mode of the object overriding the class level persist declaration. This field should be of the boolean data type.
If the persist class level annotation is true, all objects of this class type will be persisted into the underlying data store (Mirror, ExternalDataSource, Storage Adapter, Indexed File).

When using this option, you must have the space class level persist decoration specified.

Field Level Decoration - @SpaceRouting

The @SpaceRouting annotation specifies a get method for the field to be used to calculate the target space for the space operation (read , write...). The @SpaceRouting field value hash code is used to calculate the target space when the space is running in partitioned mode.

Field Level Decoration - @SpaceExclude

The @SpaceExclude annotation instructs the client to ignore the fields using this annotation, so that they are not stored within the space.

  • When IncludeProperties is defined as IMPLICIT as part of the @SpaceClass annotation, @SpaceExclude should usually be used. This is because IMPLICIT instructs the system to take all POJO fields into account.
  • When IncludeProperties is defined as EXPLICIT, there is no need to use @SpaceExclude.
  • @SpaceExclude can still be used, even if IncludeProperties is not defined.

POJO Class Example – Person and Employee

This example uses the @SpaceId, @SpaceRouting, @SpaceClass, replicate, persist, fifo, @SpaceVersion, @SpaceProperty and index annotations as part of the Person and Employee classes:

Person
package com.j_spaces.examples.hellospacepojo;
import com.gigaspaces.annotation.pojo.SpaceClass;
import com.gigaspaces.annotation.pojo.SpaceProperty;
import com.gigaspaces.annotation.pojo.SpaceProperty.IndexType;

@SpaceClass(replicate=true,persist=false,fifo=false)
public class Person
{
	private String	lastName;private String	firstName;
	public Person(){}
	public Person(String lastName, String firstName){this.lastName = lastName;this.firstName = firstName;}
	@SpaceProperty(index=IndexType.BASIC)
	public String getFirstName(){return firstName;}
	public void setFirstName(String firstName){this.firstName = firstName;}
	public String getLastName(){return lastName;}
	public void setLastName(String name) {this.lastName = name;}
}
Employee
package com.j_spaces.examples.hellospacepojo;

import com.gigaspaces.annotation.pojo.SpaceClass;
import com.gigaspaces.annotation.pojo.SpaceId;
import com.gigaspaces.annotation.pojo.SpaceRouting;
import com.gigaspaces.annotation.pojo.SpaceVersion;

@SpaceClass(replicate=true,persist=false,fifo=false)
public class Employee extends Person
{
	private Integer employeeID;
	private int versionID;
	
	public Employee(){}
	public Employee(Integer employeeID){this.employeeID = employeeID;}
	public Employee(String lastName, Integer employeeID)
	{
		this.employeeID = employeeID;
		setLastName(lastName);
	}
	
	@SpaceId
	@SpaceRouting
	public Integer getEmployeeID(){return employeeID;}

	public void setEmployeeID(Integer employeeID){this.employeeID = employeeID;}
	public String toString(){return super.toString() + ", \temployeeID: "+ employeeID ;}

	@SpaceVersion
	public int getVersionID() {return versionID;}
	public void setVersionID(int versionID) {this.versionID = versionID;}
}

Space Mapping XML File -- gs.xml

The space mapping configuration file gs.xml allows you to define space class metadata when using a POJO class with getter or setter methods. Space mapping files are also required when using POJO objects with the ExternalDataSource interface. The gs.xml configuration file is loaded when the application and space are started. gs.xml files can be edited to include GigaSpaces specific attributes.

The gs.xml file is mainly used with 1.4 JVM which does not support the Java Annotations.

gs.xml Location

The *.gs.xml file can reside in one of two locations:

  • The <CLASSPATH>/config/mapping folder. In this case, the gs.xml file can include decorations for multiple classes and can have any name. For example, the mapping file could be placed at "mpApp/config/mapping/myapplication.gs.xml", where the mpApp folder is part of the application CLASSPATH. You may have multiple gs.xml files located at the <CLASSPATH>/config/mapping folder.
  • In the same folder as the POJO class file. In this case, the gs.xml file should use the same class name as the file prefix. For example, if a POJO class is located at "mpApp/my/package/MyPojo.class" then the mapping file must located at "mpApp/my/package/MyPojo.gs.xml".

The fifo, replicate, and persist attributes must be defined (either true or false), as part of the class element.

gs.xml Example

When using the version, id and routing elements, place these in the gs.xml file in the following order:

  1. version
  2. id
  3. routing

Below is an example for an Employee class and a Person class XML configuration file named mapping.gs.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE gigaspaces-mapping PUBLIC "-//GIGASPACES//DTD GS//EN" "http://www.gigaspaces.com/dtd/6_0/gigaspaces-metadata.dtd">
<gigaspaces-mapping>
	<class name="com.j_spaces.examples.hellospacepojo.Employee" persist="false" replicate="false" fifo="false" >
		<version name="versionID" />
		<id name="employeeID" auto-generate="false" />
		<routing name="employeeID" />
		<reference
			class-ref="com.j_spaces.examples.hellospacepojo.Person" />
	</class>
	<class name="com.j_spaces.examples.hellospacepojo.Person" persist="false" replicate="false" fifo="false" >
		<property name="lastName" index="BASIC" />
		<property name="firstName" index="BASIC" />
	</class>
</gigaspaces-mapping>
The Employee class uses the <reference> tag to inherit metadata from the Person Class.

XML Tags

Class Level Tags

  • <class> – a class and the associated Java class ClassDescriptor encapsulate meta data information of a concrete class.
    Attribute Description
    name Contains the full qualified name of the specified class. Because this attribute is of the XML type ID, there can only be one class-descriptor per class.
    persist This field indicates the persistency mode of the object. When a space is defined as persistent, a true value for this annotation will persist objects of this type.

    For more details, refer to the Persistency section.

    fifo Indicates whether the POJO should be saved in FIFO order in the space. To enable FIFO-based notifications and take operations, this annotation should be true.

    For more details, refer to the FIFO operations section.

Field Level Tags

  • <property> - contains mapping info for a primitive type attribute of a persistent class.
    Attribute Description
    name Holds the name of the persistent class attribute.
    index Indicates which fields are indexed in the space. The first indexed member is used for hashing. Querying indexed fields speeds up read and take operations.
  • <reference> - contains mapping information for an attribute of a class that is not primitive, but references another entity object.
  • <null-value> - a value that will represent a null. Relevant for primitive fields (int, long).
    <class name="com.j_spaces.examples.hellospacepojo.Person" persist="false" replicate="false" fifo="false" >
    	<property name="int_Field" null-value="-1" />
    	<property name="long_Field" null-value="-1" />
    </class>
  • <class-ref> - contains the full qualified name of the specified class.
  • <id> - defines whether this field value is used when generating the object UID.
    Attribute Description
    name Specifies a get method that allows identification of the id element in the space.
    auto-generate Specifies if the object UID is generated automatically by the space when written into the space. If false, the field is indexed automatically, and if true, the field isn't indexed.
  • <version> - saves the POJO's version in the space. This must be an int data type field.
    Attribute Description
    name Specifies a get method for holding the version's ID.
  • <persist> - allows you to specify whether a POJO is or isn't saved inside the space.
    Attribute Description
    name Specifies a get method for holding the persist flag.
  • <routing> - Determines the target space for the operation with using partitioned space.
    Attribute Description
    name Specifies a get method that allows identification of the routing element in the space.
  • <exclude> - causes the POJO field under this element to be excluded, and not be saved in the space.
    • If you specify a field name that exists as part of the property element, this field is excluded.
    • If the field name doesn't exist as part of the property element, this means that this field name is part of the Person class, and you do not want it to be saved in the space.

generateGsXml Utility - Generating the gs.xml File

When a Hibernate class-to-database mapping configuration file (hbm) exists for the classes for which a space mapping configuration file gs.xml is required, a simple utility can be used to generate the gs.xml file from the hbm file.

The utility, generateGsXml, was located at <GigaSpaces Root>\bin till XAP 6.5 and it was move to OpenSpaces.org as an opensource project in XAP 6.5.

The generated space configuration file gs.xml should be located at <CLASSPATH>\config\mapping folder. GigaSpaces client and space load these files when the application and space are started.

generateGsXml Utility Options

Set the Environment variables as follows:

  • POJO_CLASSPATH - The path for the POJOs class file.
  • HIBERNATE_HOME - The path for the Hibernate configuration file and *.hbm files.

The generateGsXml command has the following parameters:

Parameter Required/Optional Description Default Value
-beanName Required if isHibernate is false. The bean (POJO) name. Represents the full path of the POJO's name.  
-outputDir required The output directory for all the generated gs.xml files.  
-is
Hibernate
optional Indicates whether to generate gs files from all *.hbm hibernate file in classpath. false
-mapping
Type
optional The mapping type can have a space value or a map value. space
-isFifo optional Indicates whether to use FIFO for all the beans. false
-isPersist optional Indicates whether to use persistent for all the beans. true
-is
Replicate
optional Indicates whether to use replicate for all the beans. true
-hibernate
ConfigFile
optional The hibernate configuration file if isHibernate is true. /hibernate.cfg.xml.
-override
File
optional Indicates whether to override an existing file with the same filename. false, meaning it will create a new file using the .new suffix.
-inherit
Indexes
optional Two values can be chosen:
  • hierarchy - takes into account the declared indexes that are set to true, and all their superclasses.
  • instance - takes into account the instance's indexes; or if it's indexes are false, takes into account the first superclass that contains indexes that are true.
true

Examples

generateGsXml -beanName com.j_spaces.examples.hellospacepojo.SimpleBean  -outputDir D:\dev\gigaspaces\
generateGsXml -isHibernate true  -outputDir D:\dev\gigaspaces\ -hibernateConfigFile hibernate.cfg.xml

POJO UID Generation and Usage Scenarios

Inserting POJOs into the Space

You can insert POJOs into the space using the write() and writeMultiple() methods. When a new object is inserted into the space, it embeds a unique ID - called the UID. The UID can be generated explicitly by the client using a unique value generated by the application business logic or using a sequencer running within the space.

The space UID for POJOs can be created in three different ways:

  • When a POJO object has no SpaceId property declared, the space generates a UID for the object.
  • When a POJO object has a property which is declared as SpaceId and marked as auto-generate=false, the UID is generated using the ClientUIDHandler utility class.
  • When a POJO object has a property which is declared as SpaceId and marked as auto-generate=true, the UID is generated by the space and placed back into the field using the relevant setter method. In this case, the field must be a java.lang.String type.

Fetching POJOs from the Space

POJOs can be fetched from the space using the methods read(), readMultiple(), readIfExists(), take(), takeMultiple(), and takeIfExists().

A POJO can be fetched from the space in different ways:

  • When a POJO has no SpaceId property declared, it will be returned without any UID. This means that update operations cannot be executed on the POJO. Only the read() and write() methods can be executed.
  • When a POJO has a property which is declared as SpaceId and auto-generate=true and its value is null, the SpaceId field will store the UID.
  • When a POJO has a property which is declared as SpaceId and auto-generate=true and its value is not null, the SpaceId field will store the original value stored within the SpaceId field.
  • When a POJO has a property which is declared as SpaceId and auto-generate=false, the SpaceId field will store the original value stored within the SpaceId field used to generate the UID.

Examples

Reading a POJO using an ID

With the following code example, the EmployeeID field is decorated using:

<id name="employeeID" auto-generate="false" />

Note the EmployeeID field should be populated with the original value used when the object has been written into the space, and not with the UID of the object.

GigaSpace space;
Employee templ = new Employee();
templ.setEmployeeID("myEmployeeID");
Employee ret = space.read(templ);

The following shows how to read Multiple objects using their ID:

GigaSpace space;
String ChildClassName = Child.class.getName();

//Converting back from list of UIDs to IDs
for (int i=0;i<childs_uid.length;i++)
{
	childs_uid[i] = ClientUIDHandler.createUIDFromName(childs_uid[i] ,ChildClassName  );
}
ExternalEntry templateUIDs = new ExternalEntry (childs_uid); 
Object results[] = space.readMultiple(templateUIDs , Integer.MAX_VALUE);
childs = new Child[results.length];
for (int i=0;i<results.length ; i++)
{
	// converting ExternalEntry to Object - this is a local call!
	childs [i] =(Child)  ((ExternalEntry) results[i]).getObject(space.getSpace());
}

Parent Child Relationship

In some cases, you might want to store Objects within the space that include references to other space Objects – i.e. an object graph.

The example code below demonstrates how ID operations handle relationships between objects.

The example writes 1000 parent-child graphs into the space.
Two types of graphs exist in the example:

  • 5 graphs with the following values for the child objects: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
  • 955 graphs with the following values for the child objects: 0, 10, 20, 30, 40, 50, 60, 70, 80, 90.


The example demonstrates a simple approach to locating all the parent objects that have two child objects with values of 1 and 2 – effectively a join operation using ID operations.

This eventually returns the 5 matching graphs.

The full example source code can be downloaded here.

Child class:

Child
package com.j_spaces.examples.parentchild;

import com.gigaspaces.annotation.pojo.SpaceClass;
import com.gigaspaces.annotation.pojo.SpaceId;
import com.gigaspaces.annotation.pojo.SpaceProperty;
import com.gigaspaces.annotation.pojo.SpaceProperty.IndexType;;

@SpaceClass
public class Child {
	
	public Child(){}
	
	public Child(String id, String parentUID) 
	{
		this.parentUID = parentUID;
		this.id = id;
	}

	public String parentUID;
	public Long field;
	public String id;
		
	public String toString()
	{
		return "ID:" + id + " data:" + field;
	}

	@SpaceProperty(index=IndexType.BASIC)
	public Long getField() {
		return field;
	}

	public void setField(Long field) {
		this.field = field;
	}
	@SpaceId (autoGenerate = false)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	@SpaceProperty(index=IndexType.BASIC)
	public String getParentUID() {
		return parentUID;
	}

	public void setParentUID(String parentUID) {
		this.parentUID = parentUID;
	}
}

Parent class:

Parent
package com.j_spaces.examples.parentchild;

import java.rmi.RemoteException;
import org.openspaces.core.GigaSpace;
import net.jini.core.entry.UnusableEntryException;
import net.jini.core.transaction.TransactionException;
import com.gigaspaces.annotation.pojo.SpaceClass;
import com.gigaspaces.annotation.pojo.SpaceId;
import com.gigaspaces.annotation.pojo.SpaceProperty;
import com.gigaspaces.annotation.pojo.SpaceProperty.IndexType;
import com.j_spaces.core.client.ClientUIDHandler;
import com.j_spaces.core.client.ExternalEntry;

@SpaceClass
public class Parent  {
	public Parent() {
	}

	public Parent(String id) {
		this.id = id;
	}

	public String childs_uid[];
	transient Child childs[];
	public Long field;
	public String id;
	
	public String _getChildsDetails(GigaSpace space) throws RemoteException, TransactionException, UnusableEntryException
	{
		String ret="";
		Child[] childs = _getChilds(space);
		for (int i=0;i<childs.length ; i++)
		{
			ret = ret + childs[i].toString() + " | ";
		}
		return ret;
		
	}

	public Child[] _getChilds(GigaSpace space) throws RemoteException, TransactionException, UnusableEntryException
	{
		if (childs == null)
		{
			String ChildClassName = Child.class.getName();
			for (int i=0;i<childs_uid.length;i++)
			{
				childs_uid[i] = ClientUIDHandler.createUIDFromName(childs_uid[i] ,ChildClassName  );
			}
			ExternalEntry templateUIDs = new ExternalEntry (childs_uid); 
			Object results[] = space.readMultiple(templateUIDs , Integer.MAX_VALUE);
			childs = new Child[results.length];
			for (int i=0;i<results.length ; i++)
			{
				childs [i] =(Child)  ((ExternalEntry) results[i]).getObject(space.getSpace());
			}
		}
		return childs;
	}
	
	public String _getChildUID()
	{
		String res ="";
		for (int i=0 ; i< childs_uid.length; i++)
		{
			res =res +childs_uid[i] + "\n";
		}
		return res;
	}


	@SpaceProperty(index=IndexType.BASIC)
	public Long getField() {
		return field;
	}

	public void setField(Long field) {
		this.field = field;
	}

	public String[] getChilds_uid() {
		return childs_uid;
	}

	public void setChilds_uid(String[] childs_uid) {
		this.childs_uid = childs_uid;
	}

	@SpaceId(autoGenerate=false)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	
}

Application:

Application
package com.j_spaces.examples.parentchild;

import java.rmi.RemoteException;
import java.util.HashSet;
import java.util.Set;
import org.openspaces.core.GigaSpace;
import org.openspaces.core.GigaSpaceConfigurer;
import org.openspaces.core.space.UrlSpaceConfigurer;
import net.jini.core.entry.UnusableEntryException;
import net.jini.core.transaction.TransactionException;
import com.j_spaces.core.client.ClientUIDHandler;
import com.j_spaces.core.client.ExternalEntry;

public class ParentChildMain {

	static GigaSpace space;
	static int max_graphs = 1000;
	static int matching_graphs = 5;

	public static void main(String[] args) {
		try {

			 UrlSpaceConfigurer urlSpaceConfigurer = new UrlSpaceConfigurer("/./mySpace");
			 space = new GigaSpaceConfigurer(urlSpaceConfigurer.space()).gigaSpace();

			 	space.clean();

			System.out.println("Write " + max_graphs+ " parent/child graphs.\nWe will have 2 types of graphs:" +
					"\n" +  matching_graphs+" graphs that got the following values for the child objects:0,1,2,3,4,5,6,7,8,9" +
					"\nand another "  +(max_graphs - matching_graphs) + "  graphs with the following values for the child objects:0,10,20,30,40,50,60,70,80,90");
			
			go();
			space.clean();
			go();
			space.clean();
			go();
			space.clean();
			go();
			
		} catch (Exception e) {
			e.printStackTrace();
		}		}
		static public void go() throws Exception
		{
			for (int i = 0; i < max_graphs; i++) {
				Parent parent = new Parent(i +"");
				Child childs[] = new Child[10];
				parent.childs_uid = new String[10];
				for (int j = 0; j < 10; j++) {
					childs[j] = new Child(i + "_" + j,	parent.getId());
					if (i% (max_graphs/matching_graphs) ==0)
						childs[j].field = new Long(j);
					else
						childs[j].field = new Long(j * 10);
						
					parent.childs_uid[j] = childs[j].getId();
				}
				space.write(parent);
				space.writeMultiple(childs);
			}

			System.out.println("Lets find all the parent object that got 2 child object with values 1 and 2 - effectively join");
			System.out.println("We need to make sure that both child objects have the same parent object");
			Long startTime = System.nanoTime();
			Object childs_results1[] = getChildsbyValue(new Long(1));
			Set set1 = getParentUIDsSet(childs_results1);

			Object childs_results2[] = getChildsbyValue(new Long(2));
			Set set2 = getParentUIDsSet(childs_results2);
			
			Set resultSet = AND(set1 , set2);

			Parent parents[] = getParentsfromUIDs(resultSet);
			Long endTime = System.nanoTime();
			System.out.println("-----------------------------------------------------------------");
			System.out.println(" --->> Found " + parents.length +" matching Parent objects in " + (double)(((double)endTime - (double)startTime)/1000000) + " ms");
			
			for (int i = 0; i < parents.length; i++) {
				System.out.println("Found Parent Object:" + parents[i]
						+ " - ID:" + parents[i].getId() + " - His children objects are:\n"
						+ parents[i]._getChildsDetails(space));
			}
	}

	static public Object[] getChildsbyValue(Long value) throws RemoteException, TransactionException, UnusableEntryException {
		Child child_template = new Child();
		child_template.field = value;
		return space.readMultiple(child_template, Integer.MAX_VALUE);
	}
	
	static public Set getParentUIDsSet(Object entries[]) {
		HashSet result = new HashSet();
		for (int i = 0; i < entries.length; i++) {
			result.add(((Child) entries[i]).parentUID);
		}
		return result;
	}

	static public Parent[] getParentsfromUIDs(Set uids) throws UnusableEntryException, RemoteException, TransactionException
	{
		Parent[] ret = null;
		String uids_str[] = new String [uids.size()]; 
		System.arraycopy(uids.toArray(),0,uids_str,0,uids_str.length);
		String parentClassName = Parent.class.getName();
		for (int i=0;i<uids_str.length;i++)
		{
			uids_str[i] = ClientUIDHandler.createUIDFromName(uids_str[i] , parentClassName );
		}
		ExternalEntry child_uids_template = new ExternalEntry(uids_str);
		Object parent_results[] = space.readMultiple(child_uids_template,Integer.MAX_VALUE);
		ret = new Parent[parent_results.length];
		for (int i=0;i<parent_results.length ; i++)
		{
			ret[i] = (Parent) ((ExternalEntry)parent_results[i]).getObject(space.getSpace());
		}
		return ret;
	}
	
	// find intersection between 2 sets with IDs
	static public Set AND(Set set1, Set set2) {
		HashSet result = new HashSet(set1);
		result.retainAll(set2);
		return result;
	}
}

Expected output:

Write 1000 parent/child graphs.
We have 2 types of graphs:
5 graphs that have the following values for the child objects:0,1,2,3,4,5,6,7,8,9
and another 995  graphs with the following values for the child objects:0,10,20,30,40,50,60,70,80,90
Lets find all the parent objects that have 2 child objects with values 1 and 2 - effectively a join operation using ID operations.
We need to make sure that both child objects have the same parent object.
-----------------------------------------------------------------
 --->> Found 5 matching Parent objects in 0.8 ms
Found Parent Object:com.j_spaces.examples.parentchild.Parent@1b5c22f - ID:200 - His children objects are:
ID:200_0 data:0 | ID:200_1 data:1 | ID:200_2 data:2 | ID:200_3 data:3 | ID:200_4 data:4 | ID:200_5 data:5 | ID:200_6 data:6 | ID:200_7 data:7 | ID:200_8 data:8 | ID:200_9 data:9 | 
Found Parent Object:com.j_spaces.examples.parentchild.Parent@1dfd90f - ID:800 - His children objects are:
ID:800_0 data:0 | ID:800_1 data:1 | ID:800_2 data:2 | ID:800_3 data:3 | ID:800_4 data:4 | ID:800_5 data:5 | ID:800_6 data:6 | ID:800_7 data:7 | ID:800_8 data:8 | ID:800_9 data:9 | 
Found Parent Object:com.j_spaces.examples.parentchild.Parent@1238785 - ID:0 - His children objects are:
ID:0_0 data:0 | ID:0_1 data:1 | ID:0_2 data:2 | ID:0_3 data:3 | ID:0_4 data:4 | ID:0_5 data:5 | ID:0_6 data:6 | ID:0_7 data:7 | ID:0_8 data:8 | ID:0_9 data:9 | 
Found Parent Object:com.j_spaces.examples.parentchild.Parent@19646fd - ID:600 - His children objects are:
ID:600_0 data:0 | ID:600_1 data:1 | ID:600_2 data:2 | ID:600_3 data:3 | ID:600_4 data:4 | ID:600_5 data:5 | ID:600_6 data:6 | ID:600_7 data:7 | ID:600_8 data:8 | ID:600_9 data:9 | 
Found Parent Object:com.j_spaces.examples.parentchild.Parent@10ebe18 - ID:400 - His children objects are:
ID:400_0 data:0 | ID:400_1 data:1 | ID:400_2 data:2 | ID:400_3 data:3 | ID:400_4 data:4 | ID:400_5 data:5 | ID:400_6 data:6 | ID:400_7 data:7 | ID:400_8 data:8 | ID:400_9 data:9 |

Troubleshooting

Using Logging

Use the com.gigaspaces.pojo.level = ALL as part of the logging file located by default at <GigaSpaces Root>\config\gs_logging.properties, to debug the POJO metadata load and conversion to space object. Having the <GigaSpaces Root> as part of the application CLASSPATH turns on the POJO debug activity at the client side.

When the POJO logging is turned on, the following should appear at the client side console when a class is introduced to the space:

FINEST [com.gigaspaces.pojo]: The annotation structure of class com.j_spaces.examples.hellospacepojo.Employee is : 
name = com.j_spaces.examples.hellospacepojo.Employee
fieldNames = [firstName, lastName, employeeID, versionID]
fieldPks = [employeeID]
fieldAutoPkGen = []
fieldIndexs = [employeeID, firstName, lastName]
hashBasedKey = []
version = [versionID]
lazyDeserialization = []
payload = []
serializationTypeFields = {}
defaultNullValueFields = {firstName=null, lastName=null}
refClasses = [com.j_spaces.examples.hellospacepojo.Person]
persist class = false
persist instance = []
routing field name = [employeeID]
timetolive = 9223372036854775807
fifo = false
inheritIndexes = true
includeProperties = IMPLICIT
replicate true
fieldTypes = null
mappingType = space
serializationType = 0
exclude = []

A converted object logging output looks like this:

FINE [com.gigaspaces.pojo]: ExternalEntry after converter is: 
	 ClassName: com.j_spaces.examples.hellospacepojo.Employee
 
	 Field Name:  firstName 
	 Field Type:  java.lang.String 
	 Field Value: first name1 
	 Field Indexed: false
 
	 Field Name:  lastName 
	 Field Type:  java.lang.String 

	 Field Value: Last Name1 
	 Field Indexed: false
 
	 Field Name:  employeeID 
	 Field Type:  java.lang.Integer 
	 Field Value: 1 
	 Field Indexed: true

Using The GUI

Use the GS-UI space class view to examine the POJO meta data. Make sure the annotations/xml decorations have been introduced to the space correctly i.e. correct class name, field names, field types, indexes, routing field, replication mode and FIFO mode etc.

GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence