Hi,
I have created a small example with the class Data and the class Test
Let me know if it works.
Alessandro
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class Data implements Serializable {
/**
*
*/
private static final long serialVersionUID = -4553633836729767354L;
private List<String> list=new ArrayList<String>();
private String name="";
public Data(){ };
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getList() {
return list;
}
public void setList(List<String> list) {
this.list = list;
}
public void addData(String... vargs){
for(String s:vargs){
list.add(s);
}
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((list == null) ? 0 : list.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Data other = (Data) obj;
if (list == null) {
if (other.list != null)
return false;
} else if (!list.equals(other.list))
return false;
return true;
}
@Override
public String toString() {
return "Data [lista=" + list + ", nome=" + name + "]";
}
}
import org.codehaus.jettison.json.JSONException;
import com.google.gson.Gson;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
public class Test {
public static void main(String[] args) throws JSONException {
OrientGraph graph = new OrientGraph("memory:test");
Data data = new Data();
data.setName("New Data");
data.addData("a","b","c");
Gson gson = new Gson();
String json = gson.toJson(data);
Vertex first = graph.addVertex(null);
first.setProperty("name","anything");
first.setProperty("allprop",json);
Vertex second = graph.addVertex(null);
second.setProperty( "name", "Marko" );
Edge lucaKnowsMarko = graph.addEdge(null, first, second, "relation");
Iterable<Vertex> result5=graph.command(new OSQLSynchQuery<Vertex>("select from V")).execute();
for(Vertex v: result5){
System.out.println(v.getProperty("name"));
System.out.println(v.getProperty("allprop"));
}
graph.shutdown();
}
}