Adam Bien's Weblog

Guardians, Tenants, NIO 2, BPM, Docker and Service Discovery, or 26th airhacks.tv

New record: >130 viewers from all over the world watched live the 26th edition of airhacks.tv discussing questions from various topics:

Any questions left? Ask now: https://gist.github.com/ and join the conversation at each first Monday of the month at 6 P.M. live. No registration or any other commitment required.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW online workshop: WebStandards Igniter (online)

Airport MUC workshops: Java EE 7: Bootstrap, Effective, Architectures, Web, React and Angular, Testing and Microservices

Newsletter: airhacks.news

A book about rethinking Java EE Patterns

Comments:

using EntityManager in @ViewScoped bean is a terrible idea. In a clustered setup, EM will try to be serialized to other cluster nodes, which will fail miserably and will cause session loss.
I use a CDI EM producer pattern and inject that instead. It's serializable and because it @ApplicationScoped, and call a get method on that to get an appropriate EM from the @ViewScoped bean.

Posted by Lenny Primak on May 11, 2016 at 05:33 PM CEST #

Batch fetching is very useful JPA optimization technique. It's used to solve N+1 issues in an efficient manner, when as opposed to join fetch, you need to retrieve multiple rows (@OneToMany) where you can retrieve using IN (1,2,3,4) etc. instead of using multiple select statements one by one

Posted by Lenny Primak on May 11, 2016 at 05:54 PM CEST #

@Lenny,

thanks! I mentioned fetch joins in earlier airhacks editions. I was not aware that Fetch Joins are also known under the name "Batch Fetching".

Fetch Joins are very useful:

SELECT d
FROM Department d LEFT JOIN FETCH d.employees
WHERE d.deptno = 1

(from the spec, chapter 4.4.5.3),

thanks and see you next month!,

cheers,

adam

Posted by 192.168.0.91 on May 11, 2016 at 07:07 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
realworldpatterns.com
Online Workshops
...the last 150 posts
...the last 10 comments
License