-
Notifications
You must be signed in to change notification settings - Fork 0
Select_en
Select is considered from the easiest commands that will enable you to query about bound objects in the database. You can execute this query on the session object by passing it throw the query(Query) method. The query method will return the selected objects by the Select query. This command has two constructors. The first one has a Class parameter that when executed will return any objects from the specified binding name that belong to the passed Class as a List. You can specify the binding name by calling the from(String) method on the Select object. The second constructor has two parameters. The first one is Class and the second one is an executable expression String. The second constructor will execute the expression on all the selected objects and will return the result of that on a List. This example will show you how to use the Select command:
public class Selection {
public static void main(String[] args) throws SofofException {
Server s = new Server(new File("sofof"), 6969, false);
s.createDatabase();
s.getUsers().add(new User("rami", "secret"));
s.startUp();
Session sess = startSession("java:localhost:6969", new User("rami", "secret"), false);
List<String> posts = sess.query(new Select(String.class).from("المنشورات"));
for(String post : posts){
System.out.println(post);
}
}