In all these tests I am using some strategies to make sure that tables and fields name generated by Hibernate will be the same as Eclipse-Link.
Definitions
- ElementCollection: Specifies a collection of instances of a basic type or embeddable class. Must be specified if the collection is to be mapped by means of a collection table.
- OneToMany: Specifies a many-valued association with one-to-many multiplicity. If the collection is defined using generics to specify the element type, the associated target entity type need not be specified; otherwise the target entity class must be specified. If the relationship is bidirectional, the
mappedBy
element must be used to specify the relationship field or property of the entity that is the owner of the relationship. TheOneToMany
annotation may be used within an embeddable class contained within an entity class to specify a relationship to a collection of entities. If the relationship is bidirectional, themappedBy
element must be used to specify the relationship field or property of the entity that is the owner of the relationship. When the collection is ajava.util.Map
, thecascade
element and theorphanRemoval
element apply to the map value.
Persistence classes scanning
Eclipse-Link
Control Loop runtime uses persistence.xml
file: is the deployment descriptor file for persistence using JPA. It specifies the persistence units and declares the managed persistence classes, the object/relation mapping, and the database connection details.
Hibernate
SpringBoot auto-configuration can automatically scan entity classes. In Control Loop Runtime we can use @EntityScan annotation because entity classes are not placed in the main application package or its sub-packages. In this situation, we need declare the package or list of packages in the main configuration class within @EntityScan annotation.
Implications using Hibernate and SpringBoot scan
persistence.xml
file doesn't contain all JPA classes in "org.onap.policy.models.tosca.simple.concepts" package, so SpringBoot will intercept additional classes (not defined into persistence.xml
file) and will generate additional tables into controlloop database for them: ToscaEventFilter, ToscaModel, ToscaServiceTemplates, ToscaServiceTemplates_ToscaServiceTemplate, ToscaTimeInterval, ToscaTrigger.
Schema generation
Boolean and TimeStamp
Eclipse-Link
MariaDB [controlloop]> describe Example;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| PRIMED | tinyint(1) | YES | | 0 | |
| timeStamp | datetime(3) | YES | | NULL | |
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+-----------+--------------+------+-----+---------+-------+
Hibernate
MariaDB [controlloop]> describe Example;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
| primed | bit(1) | YES | | NULL | |
| timeStamp | datetime(6) | YES | | NULL | |
+-----------+--------------+------+-----+---------+-------+
Boolean and TimeStamp (fixed)
Eclipse-Link
MariaDB [controlloop]> describe Example;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| PRIMED | tinyint(1) | YES | | NULL | |
| timeStamp | datetime(3) | YES | | NULL | |
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+-----------+--------------+------+-----+---------+-------+
Hibernate
MariaDB [controlloop]> describe Example;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
| primed | tinyint(1) | YES | | NULL | |
| timeStamp | datetime(3) | YES | | NULL | |
+-----------+--------------+------+-----+---------+-------+
Map and List of Strings
Eclipse-Link
MariaDB [controlloop]> describe ExampleCollection;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+---------+--------------+------+-----+---------+-------+
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleCollection_ATTRIBUTES;
+---------------------------------+---------------------------------------------------------------------------------------------------+
| Table | Create Table |
+---------------------------------+---------------------------------------------------------------------------------------------------+
| JpaExampleCollection_ATTRIBUTES | CREATE TABLE `JpaExampleCollection_ATTRIBUTES` (
`name` varchar(120) DEFAULT NULL,
`version` varchar(20) DEFAULT NULL,
`ATTRIBUTES` longtext DEFAULT NULL,
`ATTRIBUTES_KEY` varchar(255) DEFAULT NULL,
KEY `FK_JpaExampleCollection_ATTRIBUTES_name` (`name`,`version`),
CONSTRAINT `FK_JpaExampleCollection_ATTRIBUTES_name` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleCollection` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+---------------------------------+---------------------------------------------------------------------------------------------------+
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleCollection_OCCURRENCES;
+----------------------------------+--------------------------------------------------------------------------------------------------+
| Table | Create Table |
+----------------------------------+--------------------------------------------------------------------------------------------------+
| JpaExampleCollection_OCCURRENCES | CREATE TABLE `JpaExampleCollection_OCCURRENCES` (
`name` varchar(120) DEFAULT NULL,
`version` varchar(20) DEFAULT NULL,
`OCCURRENCES` varchar(255) DEFAULT NULL,
KEY `FK_JpaExampleCollection_OCCURRENCES_name` (`name`,`version`),
CONSTRAINT `FK_JpaExampleCollection_OCCURRENCES_name`
FOREIGN KEY (`name`, `version`) REFERENCES `ExampleCollection` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+----------------------------------+--------------------------------------------------------------------------------------------------+
After saving an example:
MariaDB [controlloop]> select * from ExampleCollection;
+-------------------+---------+
| name | version |
+-------------------+---------+
| ExampleCollection | 1.0.0 |
+-------------------+---------+
MariaDB [controlloop]> select * from JpaExampleCollection_ATTRIBUTES;
+-------------------+---------+-----------------+----------------+
| name | version | ATTRIBUTES | ATTRIBUTES_KEY |
+-------------------+---------+-----------------+----------------+
| ExampleCollection | 1.0.0 | ValueAttribute2 | Attribute2 |
| ExampleCollection | 1.0.0 | ValueAttribute1 | Attribute1 |
+-------------------+---------+-----------------+----------------+
MariaDB [controlloop]> select * from JpaExampleCollection_OCCURRENCES;
+-------------------+---------+-------------+
| name | version | OCCURRENCES |
+-------------------+---------+-------------+
| ExampleCollection | 1.0.0 | Occurrence1 |
| ExampleCollection | 1.0.0 | Occurrence2 |
+-------------------+---------+-------------+
Hibernate
MariaDB [controlloop]> describe ExampleCollection;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+---------+--------------+------+-----+---------+-------+
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleCollection_ATTRIBUTES;
+---------------------------------+---------------------------------------------------------------------------------------------------+
| Table | Create Table |
+---------------------------------+---------------------------------------------------------------------------------------------------+
| JpaExampleCollection_ATTRIBUTES | CREATE TABLE `JpaExampleCollection_ATTRIBUTES` (
`name` varchar(120) NOT NULL,
`version` varchar(20) NOT NULL,
`attributes` longtext DEFAULT NULL,
`attributes_KEY` varchar(255) NOT NULL,
PRIMARY KEY (`name`,`version`,`attributes_KEY`),
CONSTRAINT `FKrapsbq2h8eev8wstn9x11mfnr` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleCollection` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+---------------------------------+---------------------------------------------------------------------------------------------------+
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleCollection_OCCURRENCES;
+----------------------------------+--------------------------------------------------------------------------------------------------+
| Table | Create Table |
+----------------------------------+--------------------------------------------------------------------------------------------------+
| JpaExampleCollection_OCCURRENCES | CREATE TABLE `JpaExampleCollection_OCCURRENCES` (
`name` varchar(120) NOT NULL,
`version` varchar(20) NOT NULL,
`occurrences` varchar(255) DEFAULT NULL,
KEY `FKbvv6rdypcejif8yy1kr43vpob` (`name`,`version`),
CONSTRAINT `FKbvv6rdypcejif8yy1kr43vpob` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleCollection` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+----------------------------------+--------------------------------------------------------------------------------------------------+
After saving an example:
MariaDB [controlloop]> select * from ExampleCollection;
+-------------------+---------+
| name | version |
+-------------------+---------+
| ExampleCollection | 1.0.0 |
+-------------------+---------+
MariaDB [controlloop]> select * from JpaExampleCollection_ATTRIBUTES;
+-------------------+---------+-----------------+----------------+
| name | version | attributes | attributes_KEY |
+-------------------+---------+-----------------+----------------+
| ExampleCollection | 1.0.0 | ValueAttribute1 | Attribute1 |
| ExampleCollection | 1.0.0 | ValueAttribute2 | Attribute2 |
+-------------------+---------+-----------------+----------------+
MariaDB [controlloop]> select * from JpaExampleCollection_OCCURRENCES;
+-------------------+---------+-------------+
| name | version | occurrences |
+-------------------+---------+-------------+
| ExampleCollection | 1.0.0 | Occurrence1 |
| ExampleCollection | 1.0.0 | Occurrence2 |
+-------------------+---------+-------------+
JpaToscaCapabilityAssignment_ATTRIBUTES table
Eclipse-Link
MariaDB [controlloop]> SHOW CREATE TABLE JpaToscaCapabilityAssignment_ATTRIBUTES;
+-----------------------------------------+-------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------------------------------------+-------------------------------------------------------------------------------------------+
| JpaToscaCapabilityAssignment_ATTRIBUTES | CREATE TABLE `JpaToscaCapabilityAssignment_ATTRIBUTES` (
`name` varchar(120) DEFAULT NULL,
`version` varchar(20) DEFAULT NULL,
`ATTRIBUTES` longtext DEFAULT NULL,
`ATTRIBUTES_KEY` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+-----------------------------------------+-------------------------------------------------------------------------------------------+
Currently in controlloop database, I have not found out why foreign key has not be generated in this table and in all '_ATTRIBUTES', '_META' and '_CONSTRAINTS' tables as well.
Hibernate
MariaDB [controlloop]> SHOW CREATE TABLE JpaToscaCapabilityAssignment_ATTRIBUTES;
+-----------------------------------------+-------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------------------------------------+-------------------------------------------------------------------------------------------+
| JpaToscaCapabilityAssignment_ATTRIBUTES | CREATE TABLE `JpaToscaCapabilityAssignment_ATTRIBUTES` (
`name` varchar(120) NOT NULL,
`version` varchar(20) NOT NULL,
`attributes` longtext DEFAULT NULL,
`attributes_KEY` varchar(255) NOT NULL,
PRIMARY KEY (`name`,`version`,`attributes_KEY`),
CONSTRAINT `FKjuqj4nashp9jx76h5eh5psp7l` FOREIGN KEY (`name`, `version`)
REFERENCES `ToscaCapabilityAssignment` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+-----------------------------------------+-------------------------------------------------------------------------------------------+
Map of Objects using OneToMany
Representation of the example in YAML of what we could save using JpaExampleObjMap entity.
Eclipse-Link
MariaDB [controlloop]> describe ExampleObjMap;
+----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| EXAMPLES | longblob | YES | | NULL | |
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+----------+--------------+------+-----+---------+-------+
After saving the example:
MariaDB [controlloop]> select * from ExampleObjMap;
+--------------------------+---------------+---------+
| EXAMPLES | name | version |
+--------------------------+---------------+---------+
| .... <binary code> .... | ExampleObjMap | 1.0.0 |
+--------------------------+---------------+---------+
Removing @Lob Annotation
The keys name and version of the JpaExampleObjMap as the same as JpaExample, so Eclipse-Link creates a wrong ExampleObjMap_Example table.
MariaDB [controlloop]> describe ExampleObjMap;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+---------+--------------+------+-----+---------+-------+
MariaDB [controlloop]> SHOW CREATE TABLE ExampleObjMap_Example;
+-----------------------+-------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------------------+-------------------------------------------------------------------------------------------------------------+
| ExampleObjMap_Example | CREATE TABLE `ExampleObjMap_Example` (
`name` varchar(120) NOT NULL,
`version` varchar(20) NOT NULL,
`EXAMPLES_KEY` varchar(255) DEFAULT NULL,
PRIMARY KEY (`name`,`version`),
CONSTRAINT `FK_ExampleObjMap_Example_name` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleObjMap` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+-----------------------+-------------------------------------------------------------------------------------------------------------+
Using these tables I have got this error: Cannot add or update a child row: a foreign key constraint fails (`controlloop`.`ExampleObjMap_Example`, CONSTRAINT `FK_ExampleObjMap_Example_name` FOREIGN KEY (`name`, `version`) REFERENCES `ExampleObjMap` (`name`, `version`))
Error Code: 1452
Map of Objects using OneToMany (fixed)
Eclipse-Link
MariaDB [controlloop]> SHOW CREATE TABLE ExampleObjMap_Example;
+-----------------------+-------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------------------+-------------------------------------------------------------------------------------------------------------+
| ExampleObjMap_Example | CREATE TABLE `ExampleObjMap_Example` (
`parent_name` varchar(120) NOT NULL,
`parent_version` varchar(20) NOT NULL,
`child_name` varchar(120) NOT NULL,
`child_version` varchar(20) NOT NULL,
`EXAMPLES_KEY` varchar(255) DEFAULT NULL,
PRIMARY KEY (`parent_name`,`parent_version`,`child_name`,`child_version`),
KEY `FK_ExampleObjMap_Example_child_name` (`child_name`,`child_version`),
CONSTRAINT `FK_ExampleObjMap_Example_child_name` FOREIGN KEY (`child_name`, `child_version`)
REFERENCES `Example` (`name`, `version`),
CONSTRAINT `FK_ExampleObjMap_Example_parent_name` FOREIGN KEY (`parent_name`, `parent_version`)
REFERENCES `ExampleObjMap` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+-----------------------+-------------------------------------------------------------------------------------------------------------+
After saving the example:
MariaDB [controlloop]> select * from ExampleObjMap;
+---------------+---------+
| name | version |
+---------------+---------+
| ExampleObjMap | 1.0.0 |
+---------------+---------+
MariaDB [controlloop]> select * from Example;
+--------+-----------+----------+---------+
| PRIMED | timeStamp | name | version |
+--------+-----------+----------+---------+
| NULL | NULL | example1 | 1.0.0 |
| NULL | NULL | example2 | 1.0.0 |
+--------+-----------+----------+---------+
MariaDB [controlloop]> select * from ExampleObjMap_Example;
+---------------+----------------+------------+---------------+--------------+
| parent_name | parent_version | child_name | child_version | EXAMPLES_KEY |
+---------------+----------------+------------+---------------+--------------+
| ExampleObjMap | 1.0.0 | example1 | 1.0.0 | MyKey1 |
| ExampleObjMap | 1.0.0 | example2 | 1.0.0 | MyKey2 |
+---------------+----------------+------------+---------------+--------------+
Hibernate
MariaDB [controlloop]> SHOW CREATE TABLE ExampleObjMap_Example;
+-----------------------+-------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------------------+-------------------------------------------------------------------------------------------------------------+
| ExampleObjMap_Example | CREATE TABLE `ExampleObjMap_Example` (
`parent_name` varchar(120) NOT NULL,
`parent_version` varchar(20) NOT NULL,
`child_name` varchar(120) NOT NULL,
`child_version` varchar(20) NOT NULL,
`examples_KEY` varchar(255) NOT NULL,
PRIMARY KEY (`parent_name`,`parent_version`,`examples_KEY`),
UNIQUE KEY `UK_ma8t20i58tt5ilqjrk2ged242` (`child_name`,`child_version`),
CONSTRAINT `FK2n1x5g38x55wejkvnvhqin980` FOREIGN KEY (`parent_name`, `parent_version`)
REFERENCES `ExampleObjMap` (`name`, `version`),
CONSTRAINT `FKstwyuf69lrj4tjpafwriuwp3h` FOREIGN KEY (`child_name`, `child_version`)
REFERENCES `Example` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+-----------------------+-------------------------------------------------------------------------------------------------------------+
After saving the example:
MariaDB [controlloop]> select * from ExampleObjMap;
+---------------+---------+
| name | version |
+---------------+---------+
| ExampleObjMap | 1.0.0 |
+---------------+---------+
MariaDB [controlloop]> select * from Example;
+----------+---------+--------+-----------+
| name | version | primed | timeStamp |
+----------+---------+--------+-----------+
| example1 | 1.0.0 | NULL | NULL |
| example2 | 1.0.0 | NULL | NULL |
+----------+---------+--------+-----------+
MariaDB [controlloop]> select * from ExampleObjMap_Example;
+---------------+----------------+------------+---------------+--------------+
| parent_name | parent_version | child_name | child_version | examples_KEY |
+---------------+----------------+------------+---------------+--------------+
| ExampleObjMap | 1.0.0 | example1 | 1.0.0 | MyKey1 |
| ExampleObjMap | 1.0.0 | example2 | 1.0.0 | MyKey2 |
+---------------+----------------+------------+---------------+--------------+
Map of Objects using ElementCollection
Eclipse-Link
MariaDB [controlloop]> describe ExampleObjMapEc;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+---------+--------------+------+-----+---------+-------+
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjMapEc_EXAMPLES;
+-----------------------------+-------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------------------------+-------------------------------------------------------------------------------------------------------+
| JpaExampleObjMapEc_EXAMPLES | CREATE TABLE `JpaExampleObjMapEc_EXAMPLES` (
`name` varchar(120) DEFAULT NULL,
`version` varchar(20) DEFAULT NULL,
`EXAMPLES` longblob DEFAULT NULL,
`EXAMPLES_KEY` varchar(255) DEFAULT NULL,
KEY `FK_JpaExampleObjMapEc_EXAMPLES_name` (`name`,`version`),
CONSTRAINT `FK_JpaExampleObjMapEc_EXAMPLES_name` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleObjMapEc` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+-----------------------------+-------------------------------------------------------------------------------------------------------+
After saving the example:
MariaDB [controlloop]> select * from ExampleObjMapEc;
+---------------+---------+
| name | version |
+---------------+---------+
| ExampleObjMap | 1.0.0 |
+---------------+---------+
MariaDB [controlloop]> select * from JpaExampleObjMapEc_EXAMPLES;
+---------------+---------+---------------------------+--------------+
| name | version | EXAMPLES | EXAMPLES_KEY |
+---------------+---------+---------------------------+--------------+
| ExampleObjMap | 1.0.0 | .... <binary code> .... | MyKey1 |
| ExampleObjMap | 1.0.0 | .... <binary code> .... | MyKey2 |
+---------------+---------+---------------------------+--------------+
Hibernate
MariaDB [controlloop]> describe ExampleObjMapEc;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+---------+--------------+------+-----+---------+-------+
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjMapEc_EXAMPLES;
+-----------------------------+-------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------------------------+-------------------------------------------------------------------------------------------------------+
| JpaExampleObjMapEc_EXAMPLES | CREATE TABLE `JpaExampleObjMapEc_EXAMPLES` (
`name` varchar(120) NOT NULL,
`version` varchar(20) NOT NULL,
`examples_name` varchar(120) NOT NULL,
`examples_version` varchar(20) NOT NULL,
`examples_KEY` varchar(255) NOT NULL,
PRIMARY KEY (`name`,`version`,`examples_KEY`),
UNIQUE KEY `UK_o5b5lwcueiue1x7wf2j9l0ohb` (`examples_name`,`examples_version`),
CONSTRAINT `FKeu2s8p9mhstus32uliuwib8rr` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleObjMapEc` (`name`, `version`),
CONSTRAINT `FKf66pkeal9tdygic4pvspxhph5` FOREIGN KEY (`examples_name`, `examples_version`)
REFERENCES `Example` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+-----------------------------+-------------------------------------------------------------------------------------------------------+
After saving an example (it needs an extra step: save JpaExample objects before JpaExampleObjMapEc object):
MariaDB [controlloop]> select * from ExampleObjMapEc;
+-----------------+---------+
| name | version |
+-----------------+---------+
| ExampleObjMapEc | 1.0.0 |
+-----------------+---------+
MariaDB [controlloop]> select * from Example;
+----------+---------+--------+-----------+
| name | version | primed | timeStamp |
+----------+---------+--------+-----------+
| example1 | 1.0.0 | NULL | NULL |
| example2 | 1.0.0 | NULL | NULL |
+----------+---------+--------+-----------+
MariaDB [controlloop]> select * from JpaExampleObjMapEc_EXAMPLES;
+-----------------+---------+---------------+------------------+--------------+
| name | version | examples_name | examples_version | examples_KEY |
+-----------------+---------+---------------+------------------+--------------+
| ExampleObjMapEc | 1.0.0 | example1 | 1.0.0 | MyKey1 |
| ExampleObjMapEc | 1.0.0 | example2 | 1.0.0 | MyKey2 |
+-----------------+---------+---------------+------------------+--------------+
Map of Objects using ElementCollection (fixed)
Eclipse-Link
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjMapEc_EXAMPLES;
+-----------------------------+-------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------------------------+-------------------------------------------------------------------------------------------------------+
| JpaExampleObjMapEc_EXAMPLES | CREATE TABLE `JpaExampleObjMapEc_EXAMPLES` (
`EXAMPLES_KEY` varchar(255) DEFAULT NULL,
`PRIMED` tinyint(1) DEFAULT 0,
`timeStamp` varchar(255) DEFAULT NULL,
`child_name` varchar(255) DEFAULT NULL,
`child_version` varchar(255) DEFAULT NULL,
`name` varchar(120) DEFAULT NULL,
`version` varchar(20) DEFAULT NULL,
KEY `FK_JpaExampleObjMapEc_EXAMPLES_name` (`name`,`version`),
CONSTRAINT `FK_JpaExampleObjMapEc_EXAMPLES_name` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleObjMapEc` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+-----------------------------+-------------------------------------------------------------------------------------------------------+
After saving the example:
MariaDB [controlloop]> select * from ExampleObjMapEc;
+---------------+---------+
| name | version |
+---------------+---------+
| ExampleObjMap | 1.0.0 |
+---------------+---------+
MariaDB [controlloop]> select * from JpaExampleObjMapEc_EXAMPLES;
+--------------+--------+-----------+------------+---------------+---------------+---------+
| EXAMPLES_KEY | PRIMED | timeStamp | child_name | child_version | name | version |
+--------------+--------+-----------+------------+---------------+---------------+---------+
| MyKey2 | NULL | NULL | example2 | 1.0.0 | ExampleObjMap | 1.0.0 |
| MyKey1 | NULL | NULL | example1 | 1.0.0 | ExampleObjMap | 1.0.0 |
+--------------+--------+-----------+------------+---------------+---------------+---------+
Hibernate
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjMapEc_EXAMPLES;
+-----------------------------+-------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------------------------+-------------------------------------------------------------------------------------------------------+
| JpaExampleObjMapEc_EXAMPLES | CREATE TABLE `JpaExampleObjMapEc_EXAMPLES` (
`name` varchar(120) NOT NULL,
`version` varchar(20) NOT NULL,
`child_name` varchar(255) DEFAULT NULL,
`child_version` varchar(255) DEFAULT NULL,
`primed` bit(1) DEFAULT NULL,
`timeStamp` datetime(6) DEFAULT NULL,
`examples_KEY` varchar(255) NOT NULL,
PRIMARY KEY (`name`,`version`,`examples_KEY`),
CONSTRAINT `FKeu2s8p9mhstus32uliuwib8rr` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleObjMapEc` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+-----------------------------+-------------------------------------------------------------------------------------------------------+
After saving an example:
MariaDB [controlloop]> select * from ExampleObjMapEc;
+-----------------+---------+
| name | version |
+-----------------+---------+
| ExampleObjMapEc | 1.0.0 |
+-----------------+---------+
MariaDB [controlloop]> select * from JpaExampleObjMapEc_EXAMPLES;
+-----------------+---------+------------+---------------+--------+-----------+--------------+
| name | version | child_name | child_version | primed | timeStamp | examples_KEY |
+-----------------+---------+------------+---------------+--------+-----------+--------------+
| ExampleObjMapEc | 1.0.0 | example1 | 1.0.0 | NULL | NULL | MyKey1 |
| ExampleObjMapEc | 1.0.0 | example2 | 1.0.0 | NULL | NULL | MyKey2 |
+-----------------+---------+------------+---------------+--------+-----------+--------------+
List of Objects using ElementCollection
Eclipse-Link
MariaDB [controlloop]> describe ExampleObjListEc;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+---------+--------------+------+-----+---------+-------+
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjListEc_EXAMPLES;
+------------------------------+------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------------------------+------------------------------------------------------------------------------------------------------+
| JpaExampleObjListEc_EXAMPLES | CREATE TABLE `JpaExampleObjListEc_EXAMPLES` (
`name` varchar(120) DEFAULT NULL,
`version` varchar(20) DEFAULT NULL,
`EXAMPLES` longblob DEFAULT NULL,
KEY `FK_JpaExampleObjListEc_EXAMPLES_name` (`name`,`version`),
CONSTRAINT `FK_JpaExampleObjListEc_EXAMPLES_name` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleObjListEc` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+------------------------------+------------------------------------------------------------------------------------------------------+
After saving an example:
MariaDB [controlloop]> select * from ExampleObjListEc;
+-------------+---------+
| name | version |
+-------------+---------+
| ExampleList | 1.0.0 |
+-------------+---------+
MariaDB [controlloop]> select * from JpaExampleObjListEc_EXAMPLES;
+-------------+---------+---------------------------+
| name | version | EXAMPLES |
+-------------+---------+---------------------------+
| ExampleList | 1.0.0 | .... <binary code> .... |
| ExampleList | 1.0.0 | .... <binary code> .... |
+-------------+---------+---------------------------+
Hibernate
MariaDB [controlloop]> describe ExampleObjListEc;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+---------+--------------+------+-----+---------+-------+
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjListEc_EXAMPLES;
+------------------------------+------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------------------------+------------------------------------------------------------------------------------------------------+
| JpaExampleObjListEc_EXAMPLES | CREATE TABLE `JpaExampleObjListEc_EXAMPLES` (
`name` varchar(120) NOT NULL,
`version` varchar(20) NOT NULL,
`examples_name` varchar(120) NOT NULL,
`examples_version` varchar(20) NOT NULL,
UNIQUE KEY `UK_8nnxsomci4yiwc8ks6radimiq` (`examples_name`,`examples_version`),
KEY `FK1a58hldurq1910ne2hbm9a7af` (`name`,`version`),
CONSTRAINT `FK1a58hldurq1910ne2hbm9a7af` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleObjListEc` (`name`, `version`),
CONSTRAINT `FKnj1lga10so090q9wf38k4jf7p` FOREIGN KEY (`examples_name`, `examples_version`)
REFERENCES `Example` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+------------------------------+------------------------------------------------------------------------------------------------------+
After saving an example:
MariaDB [controlloop]> select * from Example;
+----------+---------+--------+-----------+
| name | version | primed | timeStamp |
+----------+---------+--------+-----------+
| example1 | 1.0.0 | NULL | NULL |
| example2 | 1.0.0 | NULL | NULL |
+----------+---------+--------+-----------+
MariaDB [controlloop]> select * from ExampleObjListEc;
+-------------+---------+
| name | version |
+-------------+---------+
| ExampleList | 1.0.0 |
+-------------+---------+
MariaDB [controlloop]> select * from JpaExampleObjListEc_EXAMPLES;
+-------------+---------+---------------+------------------+
| name | version | examples_name | examples_version |
+-------------+---------+---------------+------------------+
| ExampleList | 1.0.0 | example1 | 1.0.0 |
| ExampleList | 1.0.0 | example2 | 1.0.0 |
+-------------+---------+---------------+------------------+
List of Objects using ElementCollection (fixed)
Eclipse-Link
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjListEc_EXAMPLES;
+------------------------------+------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------------------------+------------------------------------------------------------------------------------------------------+
| JpaExampleObjListEc_EXAMPLES | CREATE TABLE `JpaExampleObjListEc_EXAMPLES` (
`PRIMED` tinyint(1) DEFAULT 0,
`timeStamp` varchar(255) DEFAULT NULL,
`child_name` varchar(255) DEFAULT NULL,
`child_version` varchar(255) DEFAULT NULL,
`name` varchar(120) DEFAULT NULL,
`version` varchar(20) DEFAULT NULL,
KEY `FK_JpaExampleObjListEc_EXAMPLES_name` (`name`,`version`),
CONSTRAINT `FK_JpaExampleObjListEc_EXAMPLES_name` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleObjListEc` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+------------------------------+------------------------------------------------------------------------------------------------------+
After saving an example:
MariaDB [controlloop]> select * from ExampleObjListEc;
+-------------+---------+
| name | version |
+-------------+---------+
| ExampleList | 1.0.0 |
+-------------+---------+
MariaDB [controlloop]> select * from JpaExampleObjListEc_EXAMPLES;
+--------+-----------+------------+---------------+-------------+---------+
| PRIMED | timeStamp | child_name | child_version | name | version |
+--------+-----------+------------+---------------+-------------+---------+
| NULL | NULL | example1 | 1.0.0 | ExampleList | 1.0.0 |
| NULL | NULL | example2 | 1.0.0 | ExampleList | 1.0.0 |
+--------+-----------+------------+---------------+-------------+---------+
Hibernate
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjListEc_EXAMPLES;
+------------------------------+------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------------------------+------------------------------------------------------------------------------------------------------+
| JpaExampleObjListEc_EXAMPLES | CREATE TABLE `JpaExampleObjListEc_EXAMPLES` (
`name` varchar(120) NOT NULL,
`version` varchar(20) NOT NULL,
`child_name` varchar(255) DEFAULT NULL,
`child_version` varchar(255) DEFAULT NULL,
`primed` bit(1) DEFAULT NULL,
`timeStamp` datetime(6) DEFAULT NULL,
KEY `FK1a58hldurq1910ne2hbm9a7af` (`name`,`version`),
CONSTRAINT `FK1a58hldurq1910ne2hbm9a7af` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleObjListEc` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+------------------------------+------------------------------------------------------------------------------------------------------+
After saving an example:
MariaDB [controlloop]> select * from ExampleObjListEc;
+-------------+---------+
| name | version |
+-------------+---------+
| ExampleList | 1.0.0 |
+-------------+---------+
MariaDB [controlloop]> select * from JpaExampleObjListEc_EXAMPLES;
+-------------+---------+------------+---------------+--------+-----------+
| name | version | child_name | child_version | primed | timeStamp |
+-------------+---------+------------+---------------+--------+-----------+
| ExampleList | 1.0.0 | example1 | 1.0.0 | NULL | NULL |
| ExampleList | 1.0.0 | example2 | 1.0.0 | NULL | NULL |
+-------------+---------+------------+---------------+--------+-----------+