简体   繁体   中英

OrientDB Select name of an an object followed by more than 2 users

I have this two classes :

public interface Persona {
    @Property("name")
    public void setName(String name);

    @Property("name")
    public String getName();

    @Property("surname")
    public void setSurname(String surname);

    @Property("surname")
    public int getSurname();

    @Property("age")
    public void setAge(int age);

    @Property("age")
    public int getAge();
}

and

public interface Vettura {
@Property("name")
public void setName(String name);

@Property("name")
public String getName();

@Property("model")
public void setModel(String model);

@Property("model")
public int getModel();

@Adjacency(label = "follower", direction = Direction.IN)
public Iterable<Persona> getFollowers();

@Adjacency(label = "follower",direction = Direction.IN)
public void addFollower(Persona person);
}

i am trying (without success) to write a query that display the object "Vettura" only if the followers are more than 2.

how can i write it?

i wrote this one but it give to me all the objects without the filter i desire :

for (Vertex v : (Iterable<Vertex>) graph.command(
            new OCommandSQL("   select  name from Vettura where Vettura.in('follower').count > 1 IN Vettura.in('follower') ")).execute()) {
    System.out.println("- Vettura: " + v.getVertices(Direction.BOTH, "name"));
}

thanks in advance and thanks for your attention.

Stefano

试试这个:

select from Vettura where inE('follower').size() > 1;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM