...
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 | |
+-----------+--------------+------+-----+---------+-------+
Map and List of Strings
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Entity @Table(name = "ExampleMapExampleCollection") @Data @EqualsAndHashCode public class JpaExampleMapJpaExampleCollection implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId @VerifyKey @NotNull private ExampleKey key; @ElementCollection @Lob private Map<@NotNull String, @NotNull String> attributes; @ElementCollection private List<String> occurrences; } |
Eclipse-Link
MariaDB [controlloop]> describe ExampleMapExampleCollection;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+---------+--------------+------+-----+---------+-------+
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleMapJpaExampleCollection_ATTRIBUTES;
+--------------------------+-------+---------------------------------------------------------------------------------------------------+
| Table | Create Table | Create Table |
+--------------------------+-------+---------------------------------------------------------------------------------------------------+
| JpaExampleMapJpaExampleCollection_ATTRIBUTES | CREATE TABLE `JpaExampleMap`JpaExampleCollection_ATTRIBUTES` (
`name` varchar(120) DEFAULT NULL,
`version` varchar(20) DEFAULT NULL,
`ATTRIBUTES` longtext DEFAULT NULL,
`ATTRIBUTES_KEY` varchar(255) DEFAULT NULL,
KEY KEY `FK_JpaExampleMapJpaExampleCollection_ATTRIBUTES_name` (`name`,`version`),
CONSTRAINT `FK_JpaExampleMapJpaExampleCollection_ATTRIBUTES_name` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleMap``ExampleCollection` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+--------------------------+-------+---------------------------------------------------------------------------------------------------+
Hibernate
MariaDB [controlloop]> describe ExampleMapSHOW CREATE TABLE JpaExampleCollection_OCCURRENCES;
+---------+-------------------+------+-----+----------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------------------+--------------+------+-----+---------+-------+
| name Table | varchar(120) | NOCreate Table | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+---------+--------------+------+-----+---------+-------+ |MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleMap_ATTRIBUTES;
+--------------------------+--------+--------------------------------------------------------------------------------------------------+
| TableJpaExampleCollection_OCCURRENCES | CREATE TABLE | Create Table |
+--------------------------+----------------------------------------------------------------------------------------------------------+
| JpaExampleMap_ATTRIBUTES | CREATE TABLE `JpaExampleMap_ATTRIBUTES` (
`JpaExampleCollection_OCCURRENCES` (
`name` varchar(120) DEFAULT NULL,
`version` varchar(20) DEFAULT NULL,
`OCCURRENCES` varchar(255) DEFAULT NULL,
KEY `FK_JpaExampleCollection_OCCURRENCES_name` (`name`,`version`),
`name` varchar(120) NOT NULL,
`version` varchar(20) NOT NULL,CONSTRAINT `FK_JpaExampleCollection_OCCURRENCES_name`
`attributes` longtext DEFAULT NULL,
FOREIGN `attributes_KEY` varchar(255) NOT NULL,
PRIMARY KEY (`name`,`version`,`attributes_KEY`),KEY (`name`, `version`) REFERENCES `ExampleCollection` (`name`, `version`)
CONSTRAINT `FKrwvpo54nao070vsy5p23xnps7` FOREIGN KEY (`name`, `version`)
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 REFERENCES `ExampleMap` (`name`, `version`)
|
+----------------------------------+--------------------------------------------------------------------------------------------------+
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 |
+-------------------+---------+------- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+----------+----------------+
MariaDB [controlloop]> select * from JpaExampleCollection_OCCURRENCES;
+-------------------+---------+-------------+
| name | version | occurrences |
+-------------------+---------+-------------+
| ExampleCollection | 1.0.0 | Occurrence1 |
| ExampleCollection | 1.0.0 | Occurrence2 |
+-------------------+---------+-------------+
JpaToscaCapabilityAssignment_ATTRIBUTES table
...
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 |
+-----------------------------------------+-------------------------------------------------------------------------------------------+
Implications using Hibernate
...
Map of Objects using OneToMany
...