Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does JPA actually works? [closed]

How does JPA actually works if you are using this in your project?And How is it handle the response the request when 1000 request come for the same data access at a time?

like image 652
Arpita Avatar asked Jan 19 '23 13:01

Arpita


1 Answers

JPA is basically an abstraction, using ORM techniques. If you map various model classes to the database, then JPA can a) generate an appropriate SQL query/update, b) convert the resultsets to the model classes. JPA also includes caching, and abstracts transaction handling.

In the end it doesn't really do any thing magical - everything ends up going through your JDBC driver, becoming raw SQL and returning JDBC resultsets and such. It merely allows you to hide a lot of that code away and just work with your model classes as Plain Old Java Objects (POJOs) where setting a property triggers a UPDATE and getting a property triggers a SELECT (the caching of everything and organization into transactions allows far better performance than you would get through a simple one-to-one implementation.

So your 2nd question has no real meaning - if a 1000 requests go out, it's mostly the DATABASE SERVER that has to scale and handle this, not JPA. (Admittedly it has to deal with sending them out and then marshalling them into java objects)

like image 50
MJB Avatar answered Jan 31 '23 02:01

MJB