Search in sources :

Example 1 with Airport

use of org.neo4j.ogm.domain.gh851.Airport in project neo4j-ogm by neo4j.

the class QueryCapabilityTest method createFlights.

private void createFlights() {
    // Create a few airports
    Airport lhr = new Airport("LHR", "London Heathrow");
    Airport lax = new Airport("LAX", "Los Angeles");
    Airport cdg = new Airport("CDG", "Paris Charles de Gaulle");
    // Create some flights
    session.save(new Flight("FL 001", lhr, lax));
    session.save(new Flight("FL 002", lhr, cdg));
    session.save(new Flight("FL 003", lax, lhr));
}
Also used : Flight(org.neo4j.ogm.domain.gh851.Flight) Airport(org.neo4j.ogm.domain.gh851.Airport)

Example 2 with Airport

use of org.neo4j.ogm.domain.gh851.Airport in project neo4j-ogm by neo4j.

the class QueryCapabilityTest method bothLoadStrategiesShouldBeAbleToDealWithPaths.

@Test
public void bothLoadStrategiesShouldBeAbleToDealWithPaths() {
    for (LoadStrategy strategy : new LoadStrategy[] { LoadStrategy.PATH_LOAD_STRATEGY, LoadStrategy.SCHEMA_LOAD_STRATEGY }) {
        SessionFactory localSessionFactory = new SessionFactory(getDriver(), "org.neo4j.ogm.domain.gh851");
        localSessionFactory.setLoadStrategy(strategy);
        Session session = localSessionFactory.openSession();
        Filter f = new Filter("code", ComparisonOperator.EQUALS, "LAX");
        Collection<Airport> airports = session.loadAll(Airport.class, f);
        assertThat(airports).hasSize(1).first().extracting(Airport::getName).isEqualTo("Los Angeles");
        session.clear();
    // Keep the local session factory open, otherwise closing it will mess up the driver.
    }
}
Also used : SessionFactory(org.neo4j.ogm.session.SessionFactory) Filter(org.neo4j.ogm.cypher.Filter) LoadStrategy(org.neo4j.ogm.session.LoadStrategy) Airport(org.neo4j.ogm.domain.gh851.Airport) Neo4jSession(org.neo4j.ogm.session.Neo4jSession) Session(org.neo4j.ogm.session.Session) Test(org.junit.Test)

Aggregations

Airport (org.neo4j.ogm.domain.gh851.Airport)2 Test (org.junit.Test)1 Filter (org.neo4j.ogm.cypher.Filter)1 Flight (org.neo4j.ogm.domain.gh851.Flight)1 LoadStrategy (org.neo4j.ogm.session.LoadStrategy)1 Neo4jSession (org.neo4j.ogm.session.Neo4jSession)1 Session (org.neo4j.ogm.session.Session)1 SessionFactory (org.neo4j.ogm.session.SessionFactory)1