-6

I want to select fields from two tables with Speedment ORM, and show registers by System.out.println.

This is my main query:

        return AMDB.INSTANCE.interface_Manager().stream().filter(Interface_.INTERFACEID.contains(s))
            .map(AMDB.INSTANCE.abstractcomponentManager().finderBy(Interface_.INTERFACE_COMPONENT_E_ID))
            .flatMap(AMDB.INSTANCE.concretecomponentManager().finderBackwardsBy(Concretecomponent.ABSTRACTCOMPONENT_E_ID))
            .map(cc -> cc.getConcretecomponentCamCamid())
            .collect(Collectors.toList());

And I want to get/select fields from diferent tables:

    StreamComposition.concatAndAutoClose(
            AMDB.INSTANCE.interface_Manager().stream().filter(Interface_.INTERFACEID.contains(s))
                    .map(i -> i.getInterfaceid()),

            AMDB.INSTANCE.interface_Manager().stream().filter(Interface_.INTERFACEID.contains(s))
                    .map(AMDB.INSTANCE.abstractcomponentManager().finderBy(Interface_.INTERFACE_COMPONENT_E_ID))
                    .map(ac -> ac.getComponentname()),

            AMDB.INSTANCE.interface_Manager().stream().filter(Interface_.INTERFACEID.contains(s))
                    .map(AMDB.INSTANCE.abstractcomponentManager().finderBy(Interface_.INTERFACE_COMPONENT_E_ID))
                    .flatMap(AMDB.INSTANCE.concretecomponentManager().finderBackwardsBy(Concretecomponent.ABSTRACTCOMPONENT_E_ID))
                    .map(cc -> cc.getConcretecomponentCamCamid())
    ).forEachOrdered(System.out::println);

Maybe as:

SELECT * FROM table1 INNER JOIN tabl2 ON table1.id = table2.id

or

FROM table1, table2

I have found one way:

        Map<Abstractcomponent, List<Interface_>> map0 = AMDB.INSTANCE.interface_Manager().stream().filter(Interface_.INTERFACEID.contains(s))
            .collect(Collectors.groupingBy(AMDB.INSTANCE.abstractcomponentManager().finderBy(Interface_.INTERFACE_COMPONENT_E_ID)));

But I want to achieve the fields from last joining table with the values Map<String, List<Interface_>>, where the "String is a field from "concretecomponentManager" table

Manuel
  • 205
  • 1
  • 4
  • 17

2 Answers2

0

Speedment (as of the latest release 3.0.13) does not support JOINs. However, you can create a VIEW in the database that JOINs the two tables together and then generate code from that using Speedment.

Emil Forslund
  • 549
  • 4
  • 12
0

I don't understand the example from the question, but wanted to remark that speedment actually does support joins:

Map<Actor, List<Film>> filmographies = filmActors.stream()
.collect(
    groupingBy(actors.finderBy(FilmActor.ACTOR_ID), // Applies the FilmActor to ACTOR classifier
        mapping(
            films.finderBy(FilmActor.FILM_ID), // Applies the FilmActor to Film finder
            toList()                           // Use a List collector for downstream aggregation.
        )
    )
);

See joins, many to many and pivot data.

Manuel Manhart
  • 4,819
  • 3
  • 24
  • 28