Home » 2020 » Dezember

Archiv für den Monat: Dezember 2020

Criteria API – Tutorials

https://www.objectdb.com/java/jpa/query/criteria

 

 

Criteria API: Join mit Filter auf beiden joined Tables

Der Knackpunkt is dieser:

Mit

Root<TabelleA> root = query.from(TabelleA.class)

wird die Ausgangstabelle (root) bezeichnet.

Mit

Join<TabelleA, TablleB> join = root.join(TabelleA.bRef);

wir HealthCheck hinzu ge-joined.

Wichig Referenzen (z.B. der Filter auf das Feld feldXY) müssen nun von join aus gehen:

join.get(TablleB.feldXY)

Oder die ganze Where-Clause:

.where(criteriaBuilder.equal(root.get(TabelleA.id), "id000001"),
 criteriaBuilder.like( join.get(TablleB.feldXY), "%gesuchterInhalt%"))

 

Ganze Beispiel

CriteriaBuilder criteriaBuilder = ippDaoProvider.getEntityManager().getCriteriaBuilder();
CriteriaQuery<TabelleA> query = criteriaBuilder.createQuery(TabelleA.class);
Root<TabelleA> root = query.from(TabelleA.class);
Join<TabelleA, TablleB> join = root.join(TabelleA.bRef);

String healthCheckType = "BelowInvest";
query.select(root).where(criteriaBuilder.equal(root.get(TabelleA.id), "id000001"),
        criteriaBuilder.like( join.get(TablleB.feldXY), "%gesuchterInhalt%"));

List<TabelleA> aList =  ippDaoProvider.getHealthCheckExecutionDao().find(query);

 

 

Eclipse RCP JUnit tests with SWT checks

The basing question:
How to do JUnit tests for RCP classes that create SWT GUI?

Vorgehen/Hinweise:

  • The „Run As“ dialog of Eclipse offers a „Run as Plugin“ option which must be used if OSGI features are used in the test.
  • If OSGI features are needed (e.g. an OSGI service is part of the game) than OSGI a BundleContext  has to be set up. Read OSGI Component Testing (Integration testing / “black-box-testing”) and perhaps OSGI BundleContext.java.
    If this is done, then a Bundle can be invoked/setup by FrameworkUtil.getBundle(AnyClassInTheTestPlugin.java)

To read:

OSGI Component Testing

OSGI BundleContext.java    –> siehe Mindmap unten!

Eclipse-test-plugin

Testing OSGI Based Applications –> PDF Version

Bundle Context

 

Setting up Eclipse like context for dependency injection:

If the class A has an annotation like

@Inject
C c;

Then a class A can be retrieved that has an object of C already injected like that:

IEclipseContext context = EclipseContextFactory.create("test context");
context.set(C.class, new C(...));
A a = ContextInjectionFactory.make(A.class, context);

 

Problem while running on Linux Jenkins

org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]

 

xxx

MS Access – Not in Query

In Oracle würde man schreiben:

select feldA
from Table1
where feldA not in (select feldB from Table2);

Pendent in MS Access:

SELECT feldA
FROM Table1
LEFT JOIN Table2
ON Table1.[feldA]=Table2.[feldB];