jpa sample using temp tables for optimization