Mastering Java Persistence API (JPA) Realize Javas Capabilities Spanning RDBMS, ORM, JDBC, Caching, Locking (Nisha Parameswaran Kurur) (Z-Library)

Author: Nisha Parameswaran Kurur

Java

'Mastering Java Persistence API' is geared towards experiencing the functioning of JPA and the extent of its use in Java SE and Java EE applications. While the book's primary objective is to develop competence in JPA, it also takes a simpler approach to refresh readers on basic database management system concepts and how to design simple JPA applications. The book begins with the ideas like ORM, EJB CMP, and the difficulties associated with data conversion from a database to an application and vice versa are handled spontaneously. The book discusses Table, Row, Column, Cell, and various forms of Relationships and progress sequentially through the JPA concepts. It also discusses database processes such as identity generation, sequencing, locking, querying, persisting, caching, and transaction management in detail and emphasizes how JPA handles them. Further, the book covers the architecture and setup of two of the most extensively used JPA provider implementations (Hibernate and EclipseLink) in detail. Additionally, this book includes sample functioning code for connecting to a MySQL database. Each JPA functionality is illustrated with a code snippet, making it easier to modify these features as the application develops. This book teaches both beginners and seasoned professionals how to integrate JPA concepts in their employment through numerous problems and answers spanning each of the topics.

📄 File Format: PDF
💾 File Size: 7.7 MB
37
Views
0
Downloads
0.00
Total Donations

📄 Text Preview (First 20 pages)

ℹ️

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

📄 Page 1
(This page has no text content)
📄 Page 2
(This page has no text content)
📄 Page 3
Mastering Java Persistence API (JPA) Realize Java's Capabilities Spanning RDBMS, ORM, JDBC, Caching, Locking, Transaction Management, and JPQL Nisha Parameswaran Kurur www.bpbonline.com
📄 Page 4
FIRST EDITION 2022 Copyright © BPB Publications, India ISBN: 978-93-55511-263 All Rights Reserved. No part of this publication may be reproduced, distributed or transmitted in any form or by any means or stored in a database or retrieval system, without the prior written permission of the publisher with the exception to the program listings which may be entered, stored and executed in a computer system, but they can not be reproduced by the means of publication, photocopy, recording, or by any electronic and mechanical means. LIMITS OF LIABILITY AND DISCLAIMER OF WARRANTY The information contained in this book is true to correct and the best of author’s and publisher’s knowledge. The author has made every effort to ensure the accuracy of these publications, but publisher cannot be held responsible for any loss or damage arising from any information in this book. All trademarks referred to in the book are acknowledged as properties of their respective owners but BPB Publications cannot guarantee the accuracy of this information. www.bpbonline.com
📄 Page 5
Foreword The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep. – Robert Frost The above lines from the poem “Stopping by Woods on a Snowy Evening” by Robert Frost always propel me. I think this is true for every professional, aspirant, and whoever wants to be a part of the industry. I believe learning is an endless journey for everyone; sometimes we learn from the experienced fellows the other time even a kid teaches us in a new way. The important point is learning and it does not matter from whom we are grabbing the skills. This book expounds on the above quote, and I must say, you will praise yourself once you read this book. James Gosling, Mike Sheridan, and Patrick Naughton – a great team gave us a gift of live-long technology (language and framework). It is now more than two decades since the first stable release of Java in the year 1995. Java is still famous and popular among many industries. However, there are many new adaptions and additions we have now in Java but the base fragrance of Java is the same. Gradually, this language is coming with more and more features. You have to update yourself if you want to swim in the ocean. The current book is very helpful for you to build your basic blocks with the latest terminology, additions and/or updates in this language. I appreciate the style of the author how she curated and assembled the book. This book meets its purpose as layout by the author. The author has built the basic blocks of the widely used topics in a detailed manner, and are: Object Relational Mapping. Database terminologies and their abstracts What’s new in the language? Runtime objects
📄 Page 6
The author has started with theory to define the basic concepts and visualize them in the form of dynamic diagrams. In the mid of the book, you will know the terminologies that can be used even with the help of short/tiny examples. In the final phase of the book, the author presents the difference between old and new versions. These are defined in very simple examples and in the form of images/diagrams so that one can easily grab these concepts. Additionally, the author has provided an appendix where you can find the solutions to the problems. Apart from this, every chapter has assessment sections so that the readers can assess themselves after going through a chapter. This book is built with basic blocks and can be a ready reckoner for any professional or student. You'll learn and understand them theoretically to implement various topics. After reading this book, you will realize that you are now ready to learn advanced things and if you know the advanced concepts already, then you will find yourself refreshed with the additions/updates that we have in the current version of the language. I hope you appreciate this book as much as I did. And I hope you enjoy working on database analysis. Enjoy! Dr. Gaurav Aroraa New Delhi, India
📄 Page 7
Dedicated to My beloved parentse & My cherished family
📄 Page 8
About the Author Nisha Parameswaran Kurur is a technical architect with a wide range of interests, including topics such as databases, algorithms, data structures, operating systems, and networking principles. She has worked on numerous real-world application projects for large clients in various domains like networking, broadcast, retail, finance, healthcare, etc. with different companies including services as well as product sectors from the IT industry. She earned her Master's Degree in Computer Science from the Indian Institute of Technology Madras (IITM), Chennai, India and has published conference papers and white papers. She is also a specialized coding skills instructor for courses conducted by ASAP, Kerala Government. She is deeply interested in propagating her knowledge to wider audiences and hence is involved in authoring books in local languages for non-technical people (with a great focus on next-generation kids) who have the interest to learn computer subjects.
📄 Page 9
About the Reviewers Gaurav Aroraa is a tech enthusiast and technical consultant with more than 23 years of experience in the industry. He has a Doctorate in Computer Science. Gaurav is a Microsoft MVP award recipient. He is a lifetime member of the Computer Society of India (CSI), an advisory member and senior mentor at IndiaMentor, certified as a Scrum trainer and coach, ITIL- F certified, and PRINCE-F and PRINCE-P certified. Gaurav is an open- source developer and a contributor to the Microsoft TechNet community. He has authored books across the technologies, including Microservices by Examples Using .NET Core (BPB Publications). Blog links: https://gaurav-arora.com/blog/ LinkedIn Profile: https://www.linkedin.com/in/aroragaurav/ Abhijeet Prakash has 6 years of extensive experience in Artificial Intelligence, Machine Learning, NLP, Deep Learning and Full Stack Development using tools like Cookiecutter, KerasTuner, DVC, Google Cloud Video API, Selenium, BS, Google Colab, Apigee, FastAPI, AWS, Google Cloud Platform with programming languages like Ruby, Node, Python, etc. with a demonstrated history of working in information technology and product-based companies. Abhijeet has pursued MCA from the Department of Mathematical Science and Information Technology, B.U. He has worked with various banks, NBFCs, and Fin-Tech companies. He has worked as Machine Learning Engineer and is currently working as an Artificial Intelligence Engineer. Abhijeet has also written a book on Ethical Hacking.
📄 Page 10
Acknowledgement There are quite a few people I want to thank for the continued and ongoing support they have given me. First and foremost, I would like to thank my parents for their vision and motivation, without which I would not have been what I am today. Next, I would like to thank my family for their whole-hearted and continuous encouragement and support, which has always been my pillar of strength. A special note of thanks to my kids for actively participating in my book writing activities by helping me in creating diagrams. Words fall short to explain my appreciation to my friends and teachers, right from my school to my masters, who shaped me into the person I am now. I am grateful to all my colleagues and employers (current and previous) who gave me various opportunities to learn and grow. My gratitude extends to the team at BPB Publications for handing over such a huge responsibility and being supportive enough to provide me with quite a long time to finish the book. Covid-19 pandemic and other personal interruptions kept me away from the book writing process for more time than expected. Kudos to the book coordinators at BPB, whose trust, patience, and persistence kept me going. I profoundly thank my book reviewers for doing an excellent job in a very short span of time. Overall, it was a tremendous experience that cannot be explained in words.
📄 Page 11
Preface This book covers Java persistence API – starting from its birth to the recent advancements by including different kinds of databases that are non- relational. The key focus is on the JPA concepts and their usage in different JPA providers with a special focus on Hibernate and EclipseLink. The book describes the basic concepts of a relational database that are required to understand the JPA concepts as well. It demonstrates various features of JPA with code snippets that include configuration using XML (old style) as well as annotations (new style). It also provides a good understanding of complex database concepts like locking, concurrency and transactions. The book takes a practical approach with more focus on JPA provider implementations - it focuses on two widely used implementations namely, Hibernate and EclipseLink. This book also provides sample mavenized project which can be used as a starting step for any JPA-based project creation. It also provides important JPA questions and their solutions which helps the reader to be well prepared for any interview. Chapter 1 will aim at introducing Java, and various strategies formed in Java for persisting data followed by a detailed explanation of various terms related to Object-relational model, mapping, and impedance mismatch and finally concluding with a discussion on various types of technologies that are/were used to solve the Java persistence problems. Chapter 2 will concentrate on the most widely used persistence model namely relational databases. All the basic concepts like tables, rows, columns, cells, keys, types of data, conversions, and access types are detailed out with specific mention on how these are used in JPA. Here the main aim is to introduce the relational database design concepts and their usage in JPA. It is noteworthy that configurations are given in both XML as well as annotations as much as possible. Chapter 3 will focus on operations on the relational database like identifiers and how to use them as keys. It also discusses sequencing strategies to generate identifiers, and other strategies to generate primary
📄 Page 12
keys. This chapter touches upon inheritance and locking techniques with a special interest in various locking strategies like optimistic, pessimistic, etc. Chapter 4 will discuss more on how the stored data are related to one another. This also provides a detailed discussion on various relations found in RDBMS and how they are defined in JPA as well as implemented in JPA providers. The storage of data becomes relevant only if it can be retrieved later on for reference. Chapter 5 will discuss more on how the stored data can be retrieved and what all querying mechanisms are supported in JPA. This also discusses the JPQL BNF which can be considered as a reference for those who want to go in-depth and understand the JPQL building blocks. Note that this JPQL BNF is optional and can be skipped if required. This will not cause any break in the flow of the contents. Chapter 6 will explain the Entity Manager and its role in JPA. Persisting, caching and transaction management come under this section and is helpful in understanding the important role that the Entity Manager has in any JPA implementation. Various CRUD operations performed by RDBMS become the Entity Manager’s responsibility. Chapter 7 will describe the two most widely used JPA implementations – Hibernate and EclipseLink. Both the implementations will be explained in the same structure – history, features, architecture, and querying being the main topics. A few special topics like cache architecture and poly glot persistence will also be covered as part of this. Appendix Part 1 will discuss advanced topics in JPA like events, views, stored procedures, replication, multi-tenancy, auditing, NoSQL, etc. There are many more topics that might raise interest in the reader to understand more about the relational and non-relational world of data and their object references. Appendix Part 2 will provide a sample maven project with a JPA example which can be considered as a starting project for JPA. The desired output is also mentioned so that it can be verified by the reader. This also provides a list of sample questions along with solutions or hints to the solution which aims at making the reader aware of the type of questions to be expected during an interview. Note that, for this reason, every chapter is provided
📄 Page 13
with a Q&A section and points to ponder which provides many interesting facts.
📄 Page 14
Code Bundle and Coloured Images Please follow the link to download the Code Bundle and the Coloured Images of the book: https://rebrand.ly/2mrczls The code bundle for the book is also hosted on GitHub at https://github.com/bpbpublications/Mastering-Java-Persistence-API- JPA-. In case there's an update to the code, it will be updated on the existing GitHub repository. We have code bundles from our rich catalogue of books and videos available at https://github.com/bpbpublications. Check them out! Errata We take immense pride in our work at BPB Publications and follow best practices to ensure the accuracy of our content to provide with an indulging reading experience to our subscribers. Our readers are our mirrors, and we use their inputs to reflect and improve upon human errors, if any, that may have occurred during the publishing processes involved. To let us maintain the quality and help us reach out to any readers who might be having difficulties due to any unforeseen errors, please write to us at : errata@bpbonline.com Your support, suggestions and feedbacks are highly appreciated by the BPB Publications’ Family. Did you know that BPB offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.bpbonline.com and as a print book
📄 Page 15
customer, you are entitled to a discount on the eBook copy. Get in touch with us at: business@bpbonline.com for more details. At www.bpbonline.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on BPB books and eBooks.
📄 Page 16
Piracy If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at business@bpbonline.com with a link to the material. If you are interested in becoming an author If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit www.bpbonline.com. We have worked with thousands of developers and tech professionals, just like you, to help them share their insights with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Reviews Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions. We at BPB can understand what you think about our products, and our authors can see your feedback on their book. Thank you! For more information about BPB, please visit www.bpbonline.com.
📄 Page 17
Table of Contents Section - I: Introduction 1. Java Persistence API and Object-Relational Mapping Introduction Structure Objectives Java Persistence Databases Object-Relational Definitions Object-Relational Model Object-Relational Mapping Object-Relational Impedance Mismatch Conceptual differences Data type differences Data handling differences Data Composition Differences Transactional differences Integrity differences Solution for Mismatch Java Persistence API (JPA) History of JPA Other Persistence Specs Advantages of JPA/ORM Persistence Products Conclusion Abbreviations Multiple Choice Questions Answers Questions Key Terms Points to Ponder References
📄 Page 18
2. Tables– Attributes and Embeddable Objects Introduction Structure Objectives Tables Mapping Entity class Access modes Attributes Date and time attributes Enumerations LOBs, BLOBs, CLOBs, and Serialization Lazy fetching Column definition and schema generation Insertable, updatable, read only fields Conversion Custom types Embeddables Sharing Embedded Id Nesting Inheritance Relationships Collections Querying Mapping – Advanced Multiple tables Multiple tables with foreign keys Conclusion Abbreviations Multiple choice questions Answers Questions Points to ponder References Section - II: Operations and Relationships
📄 Page 19
3. Operations – Identity, Sequencing and Locking Introduction Structure Objectives Operations Identity @EmbeddedId vs @IdClass Sequencing Table sequencing Sequencing objects Identity sequencing Advanced sequencing Primary keys for sequencing Composite primary keys Primary keys through events Inheritance Single table inheritance Joined and multiple table inheritance Advanced inheritance strategies Locking Optimistic locking Pessimistic locking Common mistakes or problems Advanced locking Timestamp locking Cascaded locking Field locking Read and write locking No locking (Ostrich locking) Locking - Best practices Conclusion Multiple choice questions Answers Questions Points to ponder 4. Relationships – Types and Strategies
📄 Page 20
Introduction Structure Objectives Relationships JPA relationship types OneToOne relationship OneToMany/ManyToOne relationship ManyToMany relationship Embedded relationship Element collections Maps Nested collections Query optimization techniques Join fetching Lazy fetching Batch fetching Variable and heterogeneous relationships Cascading Orphan removal (JPA 2.0) Target entity Nested Joins Collections Order column (JPA 2.0) Common problems Conclusion Multiple choice questions Answers Questions Points to ponder Section - III: Runtime Access and Process Objects 5. Query Infrastructure Introduction Structure Objectives Querying
The above is a preview of the first 20 pages. Register to read the complete e-book.

💝 Support Author

0.00
Total Amount (¥)
0
Donation Count

Login to support the author

Login Now
Back to List