Holon Platform JPA Module - Reference manual. Version 5.2.1

Similar documents
Holon Platform JPA Datastore Module - Reference manual. Version 5.2.1

Java Persistence API (JPA) Entities

Table of Contents. I. Pre-Requisites A. Audience B. Pre-Requisites. II. Introduction A. The Problem B. Overview C. History

Module 8 The Java Persistence API

JPA Tools Guide (v5.0)

Courses For Event Java Advanced Summer Training 2018

JPA. Java persistence API

JBPM Course Content. Module-1 JBPM overview, Drools overview

Perform Database Actions Using Java 8 Stream Syntax Instead of SQL. Emil Forslund Java Developer Speedment, Inc.

Topics covered. Introduction to Maven Maven for Dependency Management Maven Lifecycles and Plugins Hands on session. Maven 2

Pro Hibernate and. MongoDB. Anghel Leonard. Apress-

JPA Enhancement Guide (v5.1)

Cheat Sheet: Wildfly Swarm

CO Java EE 7: Back-End Server Application Development

Hibernate Change Schema Name Runtime

Pro JPA 2. Mastering the Java Persistence API. Apress* Mike Keith and Merrick Schnicariol

Component based Development. Table of Contents. Notes. Notes. Notes. Web Application Development. Zsolt Tóth

Dynamic Datasource Routing

Oracle Exam 1z0-898 Java EE 6 Java Persistence API Developer Certified Expert Exam Version: 8.0 [ Total Questions: 33 ]

Content. Development Tools 2(57)

GlassFish V3. Jerome Dochez. Sun Microsystems, Inc. hk2.dev.java.net, glassfish.dev.java.net. Session ID YOUR LOGO HERE

Spring Persistence. with Hibernate PAUL TEPPER FISHER BRIAN D. MURPHY

Spring Framework 5.0 on JDK 8 & 9

foreword to the first edition preface xxi acknowledgments xxiii about this book xxv about the cover illustration

Tutorial 4 Data Persistence in Java

Schema Null Cannot Be Resolved For Table Jpa

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?

Introducing. y Mario Fusco ed Hat Senior Software Engineer

Mobiliser CODE GENERATION - DAO-2-Service

Executable business processes in BPMN 2.0 IN ACTION. Tijs Rademakers. FOREWORDS BY Tom Baeyens. AND Joram Barrez SAMPLE CHAPTER MANNING

Session 24. Spring Framework Introduction. Reading & Reference. dev.to/lechatthecat/how-to-use-spring-boot-java-web-framework-withintellij-idea-202p

sites</distribsiteroot>

Discover how to get up and running with the Java Development Environment and with the Eclipse IDE to create Java programs.

Java EE Application Assembly & Deployment Packaging Applications, Java EE modules. Model View Controller (MVC)2 Architecture & Packaging EJB Module

JDO Tools Guide (v5.1)

Generating/Updating code from whole project

Maven. INF5750/ Lecture 2 (Part II)

Dali Java Persistence Tools

Querydsl. Reference Documentation. Timo Westkämper Samppa Saarela

CO Java EE 6: Develop Database Applications with JPA

Chapter 4 Defining Classes I

Spring ROO. Internals and add-ons. Massimiliano Dessì - SpringFramework Italian User Group Javaday IV Roma 30 gennaio 2010

Dali Java Persistence Tools. User Guide Release for Eclipse

Generating A Hibernate Mapping File And Java Classes From The Sql Schema

Creating RESTful web services with Spring Boot

Web Application Development Using Spring, Hibernate and JPA

How to be a Good Bean

Entities are classes that need to be persisted, usually in a relational database. In this chapter we cover the following topics:

Spring Professional v5.0 Exam

Rest Client for MicroProfile. John D. Ament, Andy McCright

CS1004: Intro to CS in Java, Spring 2005

Dali Java Persistence Tools. User Guide Release 2.0 for Eclipse

Rest Client for MicroProfile. John D. Ament

Hibernate OGM Architecture

Spring Framework 5.0 Themes & Trends

Example ear-testing can be browsed at

Audit SPI Implementation

JSR-303 Bean Validation. Emmanuel Bernard Doer JBoss, a Division of Red Hat

Web Application Development Using Spring, Hibernate and JPA

CMP 436/774. Introduction to Java Enterprise Edition. Java Enterprise Edition

Object-Relational Mapping

Skyway Builder 6.3 Reference

What is Transaction? Why Transaction Management Required? JDBC Transaction Management in Java with Example. JDBC Transaction Management Example

This section describes all application components, technologies and structure

Introduction to JPA. Fabio Falcinelli

QUESTIONS FOR AVERAGE BLOOMERS

Maven POM project modelversion groupid artifactid packaging version name

MAVEN MOCK TEST MAVEN MOCK TEST III

1Z Java SE 5 and 6, Certified Associate Exam Summary Syllabus Questions

BEAWebLogic. Server. Programming WebLogic Deployment

Eclipse Scout. Release Notes. Scout Team. Version 7.0

Advanced Web Systems 9- Hibernate annotations, Spring integration, Aspect Oriented Programming. A. Venturini

Example cdi-produces-field can be browsed at

JPA Entities. Course Multi Tier Business Applications with Java EE. Prof. Dr. Eric Dubuis Berner Fachhochschule Biel. Berner Fachhochschule

Supports 1-1, 1-many, and many to many relationships between objects

JavaLand Dirk Mahler

PublishMQ SPI Implementation

Web Application Development Using Spring, Hibernate and JPA

Index. setmaxresults() method, 169 sorting, 170 SQL DISTINCT query, 171 uniqueresult() method, 169

Groovy. Extending Java with scripting capabilities. Last updated: 10 July 2017

Java 10: Bridging the Gap Between Database and Stream. Per Minborg, CTO Speedment, Inc. github.com/minborg Speedment, Inc.

Selenium Online Training Brochure

Exercise for OAuth2 security. Andreas Falk

UNIT III - JDBC Two Marks

High-Level Wrapper for CloudKeeper. Architecture Configuration

Java Training For Six Weeks

Apache OpenJPA. Bean Validation Integration in JPA 2.0. July 17, Copyright 2009, The Apache Software Foundation

Chapter 13. Hibernate with Spring

Class Dependency Analyzer CDA Developer Guide

Java EE 7: Back-End Server Application Development

PSD1B Advance Java Programming Unit : I-V. PSD1B- Advance Java Programming

The Telegram component has no options. However, the Telegram component does support 24 endpoint options, which are listed below:

Deccansoft Software Services. J2EE Syllabus

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

Red Hat Decision Manager 7.0 Migrating from Red Hat JBoss BRMS 6.4 to Red Hat Decision Manager 7.0

SAP S/4HANA CLOUD SDK: EXTEND YOUR CLOUD FOUNDRY APPLICATION WITH TENANT-AWARE PERSISTENCY

What s new in IBM Operational Decision Manager 8.9 Standard Edition

Business Logic and Spring Framework

MyBatis-Spring Reference Documentation

CS 342 Software Design Fall 2018 Term Project Part II Addition of Artifacts and Data File Processing

Transcription:

Holon Platform JPA Module - Reference manual Version 5.2.1

Table of Contents 1. Introduction.............................................................................. 1 1.1. Sources and contributions............................................................. 1 2. Obtaining the artifacts.................................................................... 1 2.1. Using the Platform BOM............................................................... 2 3. What s new in version 5.2.x................................................................ 2 4. JPA entity bean post processors............................................................ 2 4.1. Post processors registration............................................................ 3 4.1.1. Direct registration................................................................. 3 4.2. JPA bean property post processors..................................................... 3 4.2.1. Entity identifiers (@Id and @EmbeddedId annotations).................................. 3 4.2.2. @Enumerated annotation............................................................ 4 4.2.3. @Temporal annotation.............................................................. 4 4.2.4. @Transient annotation............................................................. 4 4.2.5. @Column annotation................................................................ 4 4.3. JPA bean property set post processors.................................................. 4 4.3.1. @Table annotation................................................................. 4 5. Loggers.................................................................................. 5 5.1. JPA entity post processors example..................................................... 5 6. System requirements...................................................................... 7 6.1. Java.................................................................................. 7 6.2. JPA API............................................................................... 7

Copyright 2016-2018 Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically. 1. Introduction The Holon JPA module provides base support for the Java Persistence API (JPA). It makes available a set of bean post processors to deal with JPA entity annotations, which can be used to configure bean properties at bean introspection time. See the JPA Datastore documentation to learn how to use the Datastore API to manage persistent data through a JPA persistence model in an abstract and implementation independent way. 1.1. Sources and contributions The Holon Platform JPA module source code is available from the GitHub repository https://github.com/holon-platform/holon-jpa. See the repository README file for information about: The source code structure. How to build the module artifacts from sources. Where to find the code examples. How to contribute to the module development. 2. Obtaining the artifacts The Holon Platform uses Maven for projects build and configuration. All the platform artifacts are published in the Maven Central Repository, so there is no need to explicitly declare additional repositories in your project pom file. At the top of each section of this documentation you will find the Maven coordinates (group id, artifact id and version) to obtain the artifact(s) as a dependency for your project. A BOM (Bill Of Materials) pom is provided to import the available dependencies for a specific version in your projects. The Maven coordinates for the core BOM are the following: Maven coordinates:

<groupid>com.holon-platform.jpa</groupid> <artifactid>holon-jpa-bom</artifactid> <version>5.2.1</version> The BOM can be imported in a Maven project in the following way: <dependencymanagement> <dependencies> <dependency> <groupid>com.holon-platform.jpa</groupid> <artifactid>holon-jpa-bom</artifactid> <version>5.2.1</version> <strong><type>pom</type></strong> <strong><scope>import</scope></strong> </dependency> </dependencies> </dependencymanagement> 2.1. Using the Platform BOM The Holon Platform provides an overall Maven BOM (Bill of Materials) to easily obtain all the available platform artifacts. See Obtain the platform artifacts for details. 3. What s new in version 5.2.x Support for JDK 9+ module system using Automatic-Module-Name. 4. JPA entity bean post processors Maven coordinates: <groupid>com.holon-platform.jpa</groupid> <artifactid>holon-jpa-bean-processors</artifactid> <version>5.2.1</version> The holon-jpa-bean-processors artifact provides a set of Bean property and property set post processors which can be used to inspect standard JPA entity annotations on Java Beans to configure the bean properties accordingly when using the Holon Platform Property model and Bean instrospection APIs.

See the Property model documentation for information about the Holon Platform Property model and the Java Beans support documentation for information about the Holon Platform Java Beans support and the integration strategies with the Property model architecture. The Holon Platform Bean instrospection API supports two types of post processors which can be used to extend and enrich the Bean introspection strategy: The BeanPropertyPostProcessor API at property level, which allows to attend in the Bean properties introspection strategy, i.e. the process to transform each Bean property into a Holon Platform PathProperty representation, tipically to provide additional property configuration capabilities. The BeanPropertySetPostProcessor API at property set level, which allows to attend in the BeanPropertySet creation strategy, providing additional configuration capabilities. See the JPA bean property post processors and JPA bean property set post processors to learn about the available post processors. 4.1. Post processors registration The JPA post processors provided by the JPA module relies on the standard Java service extensions feature to auto-register themself in the BeanIntrospector API. This way, when the holon-jpa-bean-processors artifact is available in classpath, the JPA post processors are automatically registered and made available to the Bean introspection API. The JPA API classes must be available in classpath to enable the JPA bean post processors. 4.1.1. Direct registration When the auto registration strategy is not applicable for any reason, the JpaBeanPostProcessor API provides a static method to explicitly perform the JPA post processors registration in a BeanIntrospector API instance: registerpostprocessors(beanintrospector beanintrospector). 4.2. JPA bean property post processors 4.2.1. Entity identifiers (@Id and @EmbeddedId annotations) This post processor deals with the JPA @Id and @EmbeddedId annotations to detect the JPA entity identifier attributes. Each Bean property declared as JPA entity identifier is declared as Bean PropertySet identifier property, using the corresponding PathProperty representation. See the IdentifierProperties documentation for information about the property set identifier properties.

4.2.2. @Enumerated annotation This post processor deals with the JPA @Enumerated annotation. When the @Enumerated annotation is detected on a Bean property, the post processor configures a PropertyValueConverter for the corresponding PathProperty to automatically handle the data model value conversions to the Java enumeration type and back, using the ordinal or String representation according to the EnumType declared in the @Enumerated annotation. This post processor skips the converter setup if a PropertyValueConverter is already configured for the property, for example using the @Converter annotation. See the Builtin Bean post processors documentation section for details. 4.2.3. @Temporal annotation This post processor deals with the JPA @Temporal annotation. When the @Temporal annotation is detected on a Bean property, the TemporalType configuration attribute of the corresponding PathProperty is setted accordingly to the declared JPA temporal type value. See the PropertyConfiguration documentation for information about the property temporal type configuration attribute. 4.2.4. @Transient annotation This post processor deals with the JPA @Transient annotation. When the @Transient annotation is detected on a Bean property, that property will be ignored by the Bean introspection API and will not be part of the eventual Bean property set. 4.2.5. @Column annotation This post processor deals with the JPA @Column annotation. When the @Column annotation is detected on a Bean property or getter method and the name() attribute is provided, the column name is registered in the corresponding PathProperty configuration as data path mapping, using the DataMappable.PATH configuration property. See the DataMappable documentation for information about the data path representation. 4.3. JPA bean property set post processors 4.3.1. @Table annotation This post processor deals with the JPA @Table entity annotation. When the @Table annotation is detected on a Bean class and the name() attribute is provided, the table name is registered in the BeanPropertySet configuration as data path mapping, using the DataMappable.PATH configuration property.

See the DataMappable documentation for information about the data path representation. 5. Loggers By default, the Holon platform uses the SLF4J API for logging. The use of SLF4J is optional: it is enabled when the presence of SLF4J is detected in the classpath. Otherwise, logging will fall back to JUL (java.util.logging). The logger name for the JPA Bean Processors module is com.holonplatform.jpa.processors. 5.1. JPA entity post processors example The following example shows how the JPA post processors work during JPA entity bean introspection.

@Entity @Table(name = "mytable") public class MyEntity { 1 @Id private Long id; @Column(name = "txt") private String textvalue; @Enumerated(EnumType.ORDINAL) private MyEnum enumeration; @Temporal(javax.persistence.TemporalType.DATE) private Date date; @Transient private String toignore; } // getters and setters omitted void introspect() { BeanPropertySet<MyEntity> propertyset = BeanPropertySet.create(MyEntity.class); 2 Set<PathProperty<?>> identifiers = propertyset.getidentifiers(); 3 Optional<String> datapath = propertyset.property("textvalue").getdatapath(); 4 Optional<TemporalType> temporaltype = propertyset.property("date").gettemporaltype( ); 5 boolean ignored = propertyset.contains("toignore"); 6 } 1 A sample JPA entity definition: the JPA annotations handled by the post processors are declare at bean class and property level 2 Obtain a BeanPropertySet from the MyEntity JPA entity class using bean introspection API 3 The PathProperty with path id will be configured as property set identifier property, since the id bean property is marked with the @Id annotation 4 A data path with value txt is configured for the PathProperty with path textvalue 5 the TemporalType.DATE is is configured for the PathProperty with path date 6 Since the toignore bean property is marked with @Transient, it is ignored during bean introspection and will not be part of the bean property set

6. System requirements 6.1. Java The Holon Platform JDBC Datastore module requires Java 8 or higher. 6.2. JPA API The JPA API classes must be present in classpath to enable JPA beans processing. The Holon JPA module is tested against the JPA API version 2.0, 2.1 and 2.2.