...
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 |
+-----------------------------+-------------------------------------------------------------------------------------------------------+
...
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 |
+-----------------------------+-------------------------------------------------------------------------------------------------------+
...
Map of Objects using ElementCollection (hacked)
In this scenario JpaExampleEmd JpaExampleLob class is not entity and neither embedded.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Data public class JpaExampleEmdJpaExampleLob implements Serializable { private static final long serialVersionUID = 1L; @VerifyKey @NotNull private ExampleKey key; private Boolean primed; @NotNull private Date timeStamp; } @Entity @Table(name = "ExampleObjMapEc") @Data public class JpaExampleObjMapEc implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId @VerifyKey @NotNull private ExampleKey key; @ElementCollection @Lob private Map<@NotNull String, @NotNull JpaExampleEmd>JpaExampleLob> examples; } |
JpaToscaDataType_PROPERTIES table
The SQL code below shows JpaToscaDataType_PROPERTIES table.
Eclipse-Link
Hibernate
MariaDB [controlloop]> describe JpaToscaDataType_PROPERTIESSHOW CREATE TABLE JpaExampleObjMapEc_EXAMPLES;
+-----------------------------+-------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| Table name | Create Table |
+-----------------------------+-------------------------------------------------------------------------------------------------------+
| JpaExampleObjMapEc_EXAMPLES | CREATE TABLE `JpaExampleObjMapEc_EXAMPLES` (
`name` varchar(120) NOT NULL,
`version` varchar(20) NOT NULL,
`examples` longblob 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 JpaExampleObjMapEc_EXAMPLES;
+-----------------+---------+---------------------------+--------------+
| name | version | examples | examples_KEY |
+-----------------+---------+---------------------------+--------------+
| ExampleObjMapEc | 1.0.0 | .... <binary code> .... | MyKey1 |
| ExampleObjMapEc | 1.0.0 | .... <binary code> .... | MyKey2 |
+-----------------+---------+---------------------------+--------------+
JpaToscaDataType_PROPERTIES table
The SQL code below shows JpaToscaDataType_PROPERTIES table.
Eclipse-Link
MariaDB [controlloop]> describe JpaToscaDataType_PROPERTIES;
+----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| name | varchar| varchar(120) | YES | | NULL | |
| version | varchar(20) | YES | | NULL | |
| PROPERTIES | longblob | YES | | NULL | |
| PROPERTIES_KEY | varchar(255) | YES | | NULL | |
+----------------+--------------+------+-----+---------+-------+
MariaDB [controlloop]> SELECT count(1) FROM `JpaToscaDataType_PROPERTIES`;
+----------+
| count(1) |
+----------+
| 41 |
+----------+
MariaDB [controlloop]> describe ToscaProperty;
+------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+-------+
| DEFAULTVALUE | varchar(255) | YES | | NULL | |
| DESCRIPTION | varchar(255) | YES | | NULL | |
| ENTRYSCHEMA | longblob | YES | | NULL | |
| REQUIRED | tinyint(1) | YES | | 0 | |
| STATUS | int(11) | YES | | NULL | |
| parentLocalName | varchar(120) | NO | PRI | NULL | |
| localName | varchar(120) | NO | PRI | NULL | |
| parentKeyVersion | varchar(15) | NO | PRI | NULL | |
| parentKeyName | varchar(120) | NO | PRI | NULL | |
| name | varchar(120) | YES | | NULL | |
| version | varchar(20) | YES | | NULL | |
+------------------+--------------+------+-----+---------+-------+
MariaDB [controlloop]> SELECT count(1) FROM ToscaProperty;
+----------+
| count(1) |
+----------+
| 0 |
+----------+
...
Right now JpaToscaProperty will generate ToscaProperty table but this one will never used. Moving JpaToscaProperty as embeddable class, all max length in varchar fields will be applied.
List of Objects using ElementCollection
...
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 |
+------------------------------+------------------------------------------------------------------------------------------------------+
...
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 |
+------------------------------+------------------------------------------------------------------------------------------------------+
...
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;
...