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.
...
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.
...
Boolean and TimeStamp (fixed)
columnDefinitionwill override the sql DDL generated by hibernate for this particular column, but it is non portable.
Code Block | ||||
---|---|---|---|---|
| ||||
@Entity @Table(name = "Example") @Data public class JpaExample implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId @VerifyKey @NotNull private ExampleKey key; @Column(columnDefinition ="tinyint(1)") private Boolean primed; @Column(name = "timeStamp", precision = 3, columnDefinition = "datetime(3)") @Temporal(TemporalType.TIMESTAMP) @NotNull private Date timeStamp; } |
...
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
...
ElementCollection
ElementCollection should be used with basic type or embeddable class, this example shows side effects using it with entity.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Entity @Table(name = "ExampleObjMapExampleObjMapEc") @Data public class JpaExampleObjMapJpaExampleObjMapEc implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId @VerifyKey @NotNull private ExampleKey key; @OneToMany(fetch@ElementCollection = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) @Lob private Map<@NotNull String, @NotNull JpaExample> examples; } |
Representation of the example in YAML of what we could save using JpaExampleObjMap entity.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
ExampleObjMap:
name: ExampleObjMap
version: 1.0.0
examples:
MyKey1:
name: example1
version: 1.0.0
MyKey2:
name: example2
version: 1.0.0 |
Eclipse-Link
...
Eclipse-Link
MariaDB [controlloop]> describe ExampleObjMapExampleObjMapEc;
+----------+--------------+------+-----+---------+-------+
| 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]> selectSHOW *CREATE fromTABLE ExampleObjMapJpaExampleObjMapEc_EXAMPLES;
+-----------------------------+---------------+-----------+
| EXAMPLES -----------------------------------------------------------------------------+
| Table | name | Create Table | version |
+-----------------------------+---------------+-----------+
| .... <binary code> .... | ExampleObjMap | 1.0.0 |
+--------------------------+---------------+---------+
Removing @Lob Annotation
...
-
...
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` (
| 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` varchar(120) NOT NULL,
`version` varchar(20) NOT NULL(`name`,`version`),
`EXAMPLES_KEY` varchar(255) DEFAULT NULL,
PRIMARY KEY (`name`,`version`),
CONSTRAINT `FK_ExampleObjMapJpaExampleObjMapEc_ExampleEXAMPLES_name` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleObjMap``ExampleObjMapEc` (`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)
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Entity
@Table(name = "ExampleObjMap")
@Data
public class JpaExampleObjMap implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
@VerifyKey
@NotNull
private ExampleKey key;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(
joinColumns = {@JoinColumn(name = "parent_name", referencedColumnName = "name"),
@JoinColumn(name = "parent_version", referencedColumnName = "version")},
inverseJoinColumns = {@JoinColumn(name = "child_name", referencedColumnName = "name"),
@JoinColumn(name = "child_version", referencedColumnName = "version")})
private Map<@NotNull String, @NotNull JpaExample> examples;
} |
Eclipse-Link
...
After saving an 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;
+---------+--------------+------+-----+---------+-------------------------+
| Table +
| Field | Type | CreateNull Table| Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+---------+--------------+------+-----+---------+------------+
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjMapEc_EXAMPLES;
+-----------------------------+-------------------------------------------------------------------------------------------------------+
| ExampleObjMap_ExampleTable | CREATE TABLE `ExampleObjMap_Example` (
`parent_name` varchar(120) NOT NULL,
`parent_version` varchar(20) NOT NULL,
| Create Table |
+-----------------------------+-------------------------------------------------------------------------------------------------------+
| JpaExampleObjMapEc_EXAMPLES | CREATE TABLE `JpaExampleObjMapEc_EXAMPLES` (
`child_name``name` varchar(120) NOT NULL,
`child_version``version` varchar(20) NOT NULL,
`EXAMPLES`examples_KEY`name` varchar(255120) DEFAULTNOT NULL,
PRIMARY KEY (`parent_name`,`parent_version`,`child_name`,`child_version`),
`examples_version` varchar(20) NOT NULL,
KEY `FK_ExampleObjMap_Example_child_name` (`child_name`,`child_version`),
CONSTRAINT `FK_ExampleObjMap_Example_child_name` FOREIGN KEY (`child_name`, `child_version`)`examples_KEY` varchar(255) NOT NULL,
PRIMARY KEY REFERENCES `Example` (`name`, `version`,`examples_KEY`),
CONSTRAINT `FK_ExampleObjMap_Example_parent_name` FOREIGN KEY (`parent_name`, `parent_version`) UNIQUE KEY `UK_o5b5lwcueiue1x7wf2j9l0ohb` (`examples_name`,`examples_version`),
REFERENCES `ExampleObjMap` CONSTRAINT `FKeu2s8p9mhstus32uliuwib8rr` FOREIGN KEY (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 REFERENCES `ExampleObjMapEc` (`name`, `version`),
CONSTRAINT `FKf66pkeal9tdygic4pvspxhph5` FOREIGN KEY (`examples_name`, `examples_version`)
REFERENCES `Example` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+-----------------------+------+-------------------------------------------------------------------------------------------------------+
After saving the example:an example (it needs an extra step: save JpaExample objects before JpaExampleObjMapEc object):
MariaDB [controlloop]> select * from ExampleObjMapExampleObjMapEc;
+-----------------+---------+
| name | version |
+-----------------+---------+
| ExampleObjMapExampleObjMapEc | 1.0.0 |
+-----------------+---------+
MariaDB [controlloop]> select * from Example;
+--------+--+---------+--------+--+---------+
| PRIMEDname | timeStamp | nameversion | primed | versiontimeStamp |
+--------+--+---------+--------+--+---------+
| example1 | 1.0.0 | NULL | NULL |
| example1example2 | 1.0.0 |
| NULL NULL | NULL | example2 | 1.0.0 |
+--------+--+---------+--------+--+---------+
MariaDB [controlloop]> select * from ExampleObjMapJpaExampleObjMapEc_ExampleEXAMPLES;
+-----------------+----------+------+---------+---+---------------+--------------+
| parent_name | parent_version | childexamples_name | childexamples_version | EXAMPLESexamples_KEY |
+-----------------+---------+-------+--------+----+---------------+--------------+
| ExampleObjMapExampleObjMapEc | 1.0.0 | example1 | example1 | 1.0.0 | MyKey1 |
| ExampleObjMapExampleObjMapEc | 1.0.0 | example2 | example2 | 1.0.0 | MyKey2 |
+-----------------+----------+------+---------+---+---------------+--------------+
Hibernate
MariaDB [controlloop]> SHOW CREATE TABLE ExampleObjMap_Example;
...
Map of Objects using ElementCollection (fixed)
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Data
@Embeddable
public class JpaExampleEmd implements Serializable {
private static final long serialVersionUID = 1L;
@VerifyKey
@NotNull
@AttributeOverride(name = "name", column = @Column(name = "child_name"))
@AttributeOverride(name = "version", column = @Column(name = "child_version"))
private ExampleKey key;
@Column
private Boolean primed;
@Column(name = "timeStamp", precision = 3)
@Temporal(TemporalType.TIMESTAMP)
@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
private Map<@NotNull String, @NotNull JpaExampleEmd> examples;
} |
Eclipse-Link
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjMapEc_EXAMPLES;
+-----------------------------+---------------------------------------------------------+
| ExampleObjMap_Example | CREATE TABLE `ExampleObjMap_Example` (
`parent_name` varchar(120) NOT NULL,
`parent_version` varchar(20) NOT NULL,
----------------------------------------------+
| Table | Create Table `child_name` varchar(120) NOT NULL,
`child_version` varchar(20) NOT NULL,
`examples_KEY` varchar(255) NOT NULL,
|
+-----------------------------+-------------------------------------------------------------------------------------------------------+
| JpaExampleObjMapEc_EXAMPLES | CREATE TABLE `JpaExampleObjMapEc_EXAMPLES` (
PRIMARY KEY (`parent_name`,`parent_version`,`examples_KEY`),
`EXAMPLES_KEY` varchar(255) DEFAULT NULL,
UNIQUE KEY `UK_ma8t20i58tt5ilqjrk2ged242``PRIMED` (`child_name`,`child_version`)tinyint(1) DEFAULT 0,
CONSTRAINT `FK2n1x5g38x55wejkvnvhqin980` FOREIGN KEY (`parent_name`, `parent_version`)
`timeStamp` varchar(255) DEFAULT NULL,
`child_name` varchar(255) REFERENCES `ExampleObjMap` (`name`, `version`),
DEFAULT NULL,
CONSTRAINT `FKstwyuf69lrj4tjpafwriuwp3h` FOREIGN KEY (`child_name`, `child_version` varchar(255) DEFAULT NULL,
`name` varchar(120) DEFAULT NULL,
REFERENCES `Example` (`name`, `version`)
`version` varchar(20) DEFAULT NULL,
KEY `FK_JpaExampleObjMapEc_EXAMPLES_name` (`name`,`version`),
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 CONSTRAINT `FK_JpaExampleObjMapEc_EXAMPLES_name` FOREIGN KEY (`name`, `version`)
|
REFERENCES `ExampleObjMapEc` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+-----------------------+------+-------------------------------------------------------------------------------------------------------+
...
MariaDB [controlloop]> select * from ExampleObjMapExampleObjMapEc;
+---------------+---------+
| name | version |
+---------------+---------+
| ExampleObjMap | 1.0.0 |
+---------------+---------+
MariaDB [controlloop]> select * from ExampleJpaExampleObjMapEc_EXAMPLES;
+--------------+--------+---+--------+-----------+
| name | version | primed | timeStamp |
+-+-----------+----+-----+--------+--+---------+
| example1EXAMPLES_KEY | 1.0.0 PRIMED | NULLtimeStamp | NULL |
| example2child_name | child_version | 1.0.0name | NULL | NULL version |
+----------+---------+--------+-----------+
MariaDB [controlloop]> select * from ExampleObjMap_Example;
+---------------+----------------+------------+---------------+--------------+
| parent_name | parent_version | child_name | child_version | examples_KEY MyKey2 | NULL | NULL | example2 | 1.0.0 | ExampleObjMap | 1.0.0 |
| MyKey1 | NULL | NULL | example1 | 1.0.0 | ExampleObjMap | 1.0.0 |
+---------------+--------+--------+---+------------+---------------+---------------+
| ExampleObjMap | 1.0.0 | example1 | 1.0.0 | MyKey1 |
| ExampleObjMap | 1.0.0 | example2 | 1.0.0 | MyKey2 |
+---------+
Hibernate
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjMapEc_EXAMPLES;
+-----------------------------+------------------+---------------------------+---------------+--------------+
Map of Objects using ElementCollection
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@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 JpaExample> examples;
} |
Eclipse-Link
MariaDB [controlloop]> describe ExampleObjMapEc;
+-----------------------------+
| Table | Create Table |
+---------------+--------------+---------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------------+--------------+------+-----+---------+-------+
| name | JpaExampleObjMapEc_EXAMPLES | CREATE TABLE `JpaExampleObjMapEc_EXAMPLES` (
`name` varchar(120) | NO | PRI | NULL | |
| version | NOT NULL,
`version` varchar(20) | NO | PRI | NULL | |
+---------+--------------+------+-----+---------+-------+MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjMapEc_EXAMPLES;
+-----------------------------+-------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------------------------+-------------------------------------------------------------------------------------------------------+
| JpaExampleObjMapEc_EXAMPLES | CREATE TABLE `JpaExampleObjMapEc_EXAMPLES` (
NOT NULL,
`name` varchar(120`child_name` varchar(255) DEFAULT NULL,
`version``child_version` varchar(20255) DEFAULT NULL,
`EXAMPLES` longblob`primed` bit(1) DEFAULT NULL,
`EXAMPLES_KEY``timeStamp` varchardatetime(2556) DEFAULT NULL,
KEY `FK_JpaExampleObjMapEc_EXAMPLES_name` (`name`,`version`),
CONSTRAINT `FK_JpaExampleObjMapEc_EXAMPLES_name` FOREIGN KEY (`name`, `version`)
`examples_KEY` varchar(255) NOT NULL,
REFERENCES `ExampleObjMapEc` (`name`, `version`)
PRIMARY KEY (`name`,`version`,`examples_KEY`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 CONSTRAINT `FKeu2s8p9mhstus32uliuwib8rr` FOREIGN KEY (`name`, `version`)
|
+-----------------------------+-------------------------------------------------------------------------------------------------------+
After saving the example:
MariaDB [controlloop]> select * from ExampleObjMapEc;
+---------------+---------+
| name | version |
+---------------+---------+
| ExampleObjMap | 1.0.0 REFERENCES `ExampleObjMapEc` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+---------------+--------------+
MariaDB [controlloop]> select * from JpaExampleObjMapEc_EXAMPLES;
+---------------+---------+---------------------------+--------------+
| name | version | EXAMPLES | EXAMPLES_KEY |
+---------------+---------+---------------+
After saving an example:
MariaDB [controlloop]> select * from ExampleObjMapEc;
+------------+-----+---------+
| ExampleObjMapname | 1.0.0 | .... <binary code> .... | MyKey1 |version |
+-----------------+---------+
| ExampleObjMapExampleObjMapEc | 1.0.0 | .... <binary code> .... | MyKey2 |
+-----------------+---------+
MariaDB [controlloop]> select * from JpaExampleObjMapEc_EXAMPLES;
+------------------+---------+--------------+
Hibernate
MariaDB [controlloop]> describe ExampleObjMapEc;
+---------+------+--------+------+-----+---------+-------+
| Fieldname | Type | version | child_name | Nullchild_version | Keyprimed | DefaulttimeStamp | Extraexamples_KEY |
+-----------------+---------+------------+---------------+--------+-----------+--------------+
| ExampleObjMapEc | name1.0.0 | example1 | varchar(120) | NO1.0.0 | NULL PRI | NULL | MyKey1 |
| ExampleObjMapEc | version 1.0.0 | varchar(20)example2 | NO 1.0.0 | NULL PRI | NULL | MyKey2 |
+---------+--------------+------+-----+---------+-------+
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjMapEc_EXAMPLES;
+---------------------+--------+-----------+--------------------------------------------------------------------------------------------+
| Table | Create Table |+
List of Objects using ElementCollection
ElementCollection should be used with basic type or embeddable class, this example shows side effects using it with entity.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Entity
@Table(name = "ExampleObjListEc")
@Data
public class JpaExampleObjListEc implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
@VerifyKey
@NotNull
private ExampleKey key;
@ElementCollection
@Lob
private List<@NotNull JpaExample> examples;
} |
Eclipse-Link
MariaDB [controlloop]> describe ExampleObjListEc;
+---------+--------------+------+---------------------------------------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-----+
| JpaExampleObjMapEc_EXAMPLES | CREATE TABLE `JpaExampleObjMapEc_EXAMPLES` (
`name` varchar(120) NOT NULL,
`version` varchar(20) NOT NULL,
`examples_name`--+
| name | varchar(120) NOT| NULL,
NO | PRI | NULL | |
| version `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`) | NO | PRI | NULL | |
+---------+--------------+------+-----+---------+-------+
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjListEc_EXAMPLES;
+------------------------------+------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------------------------+------------------------------------------------------------------------------------------------------+
| JpaExampleObjListEc_EXAMPLES | CREATE TABLE `JpaExampleObjListEc_EXAMPLES` (
`name` varchar(120) DEFAULT NULL,
REFERENCES `ExampleObjMapEc` (`name`, `version`),
CONSTRAINT `FKf66pkeal9tdygic4pvspxhph5` FOREIGN KEY (`examples_name`, `examples_version`)
`version` varchar(20) DEFAULT NULL,
REFERENCES `Example` (`name`, `version`)
`EXAMPLES` longblob DEFAULT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 KEY `FK_JpaExampleObjListEc_EXAMPLES_name` (`name`,`version`),
CONSTRAINT `FK_JpaExampleObjListEc_EXAMPLES_name` |
+-----------------------------+-------------------------------------------------------------------------------------------------------+
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;
+-----------------+---------+---------------+--FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleObjListEc` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+----------------+--------------+
| name | version | examples_name | examples_version | examples_KEY |
++----------------------------------------------+---------+---------------+------------------+--------------+| ExampleObjMapEc | 1.0.0 | example1
After saving an example:
MariaDB [controlloop]> select * from ExampleObjListEc;
+-------------+---------+
| name | 1.0.0 | MyKey1 |version |
+-------------+---------+
| ExampleObjMapEc | 1.0.0 | example2 | 1.0.0 | MyKey2 ExampleList | 1.0.0 |
+-------------+----+-----+
MariaDB [controlloop]> select * from JpaExampleObjListEc_EXAMPLES;
+----+---------+------+---+---------------+--------------+
Map of Objects using ElementCollection (fixed)
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Data
@Embeddable
public class JpaExampleEmd implements Serializable {
private static final long serialVersionUID = 1L;
@VerifyKey
@NotNull
@AttributeOverride(name = "name", column = @Column(name = "child_name"))
@AttributeOverride(name = "version", column = @Column(name = "child_version"))
private ExampleKey key;
@Column
private Boolean primed;
@Column(name = "timeStamp", precision = 3)
@Temporal(TemporalType.TIMESTAMP)
@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
private Map<@NotNull String, @NotNull JpaExampleEmd> 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 JpaExampleObjMapEcJpaExampleObjListEc_EXAMPLES;
+------------------------------+-------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+ |
+------------------------------+-------------------------------------------------------------------------------------------------------+
| JpaExampleObjMapEcJpaExampleObjListEc_EXAMPLES | CREATE TABLE `JpaExampleObjMapEc`JpaExampleObjListEc_EXAMPLES` (
`EXAMPLES_KEY``name` varchar(255120) DEFAULTNOT NULL,
`PRIMED` tinyint(1) DEFAULT 0,
`timeStamp` `version` varchar(25520) DEFAULTNOT NULL,
`child`examples_name` varchar(255120) DEFAULTNOT NULL,
`child`examples_version` varchar(25520) DEFAULTNOT NULL,
`name` varchar(120) DEFAULT NULL,
UNIQUE KEY `UK_8nnxsomci4yiwc8ks6radimiq` (`examples_name`,`examples_version`),
`version` varchar(20) DEFAULT NULL,
KEY `FK_JpaExampleObjMapEc_EXAMPLES_name``FK1a58hldurq1910ne2hbm9a7af` (`name`,`version`),
CONSTRAINT `FK_JpaExampleObjMapEc_EXAMPLES_name``FK1a58hldurq1910ne2hbm9a7af` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleObjMapEc``ExampleObjListEc` (`name`, `version`),
) ENGINE=InnoDB DEFAULTCONSTRAINT CHARSET=utf8mb4`FKnj1lga10so090q9wf38k4jf7p` FOREIGN KEY (`examples_name`, `examples_version`)
|
+-----------------------------+-------------------------------------------------------------------------------------------------------+
After saving the example:
MariaDB [controlloop]> select * from ExampleObjMapEc;
+---------------+---------+
| name | version |
+---------------+---------+
| ExampleObjMap | 1.0.0 REFERENCES `Example` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+---------------+-----------+
MariaDB [controlloop]> select * from JpaExampleObjMapEc_EXAMPLES;
+----+----------+--------+-----------+------------+---------------+---------------+---------+
| EXAMPLES_KEY | PRIMED | timeStamp | child_name | child_version | name | version |
+--------------+--------+
After saving an example:
MariaDB [controlloop]> select * from Example;
+-----------+------------+--------+-------+----+
| name | version | primed | timeStamp |
+-----------+---------+
| MyKey2 | NULL | NULL | example2 --------+-----------+
| example1 | 1.0.0 | ExampleObjMap | 1.0.0 NULL |
| MyKey1NULL | NULL
| NULL | example1 | example2 | 1.0.0 | NULL | ExampleObjMapNULL | 1.0.0 |
+----------+----+-----+---+-----+------+-----+
MariaDB [controlloop]> select * from ExampleObjListEc;
+-------+------+---------+--
| name | version |
+-------------+---------+
Hibernate
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjMapEc_EXAMPLES;| ExampleList | 1.0.0 |
+----------------+---------+
MariaDB [controlloop]> select * from JpaExampleObjListEc_EXAMPLES;
+--------------+---------+---------------+------------------+
| name | version | examples_name | examples_version |
+-------------+---------+---------------+------------------------+
| ExampleList | Table1.0.0 | example1 | 1.0.0 |
| CreateExampleList Table | 1.0.0 | example2 | 1.0.0 |
+-----------------------------+----------------------------------------------|
+-------------+---------+-----------------+------------------+| JpaExampleObjMapEc_EXAMPLES | CREATE TABLE `JpaExampleObjMapEc_EXAMPLES` (
`name` varchar(120) NOT NULL,
`version` varchar(20) NOT NULL,
`child_name` varchar(255) DEFAULT NULL,
List of Objects using ElementCollection (fixed)
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Entity @Table(name = "ExampleObjListEc") @Data public class JpaExampleObjListEc implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId @VerifyKey |
...
|
...
|
...
|
...
@NotNull |
...
private ExampleKey key; @ElementCollection private List<@NotNull JpaExampleEmd> examples; } |
Eclipse-Link
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjListEc_EXAMPLES;
+------------------------------+------------------------------------------------------------------------------------------------------+
| Table `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`)
| Create Table |
+------------------------------+------------------------------------------------------------------------------------------------------+
| JpaExampleObjListEc_EXAMPLES | CREATE TABLE `JpaExampleObjListEc_EXAMPLES` (
`PRIMED` REFERENCES `ExampleObjMapEc` (`name`, `version`)
tinyint(1) DEFAULT 0,
) ENGINE=InnoDB`timeStamp` varchar(255) DEFAULT CHARSET=utf8mb4NULL,
`child_name` varchar(255) DEFAULT NULL,
|
+-----------------------------+-------------------------------------------------------------------------------------------------------+
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 |
+ `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 |
+------------------------------+---------------------------------+---------+------------+---------------+--------+-----------+--------------+
List of Objects using ElementCollection
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Entity
@Table(name = "ExampleObjListEc")
@Data
public class JpaExampleObjListEc implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
@VerifyKey
@NotNull
private ExampleKey key;
@ElementCollection
@Lob
private List<@NotNull JpaExample> examples;
} |
...
After saving an example:
MariaDB [controlloop]> select * from ExampleObjListEc;
+-------------+---------+
| name | version |
+-------------+---------+
| ExampleList | 1.0.0 |
+-------------+---------+
MariaDB [controlloop]> describe ExampleObjListEc;
select * from JpaExampleObjListEc_EXAMPLES;
+--------+-----------+------------+--+--------+-----+-------------+---------+
| FieldPRIMED | TypetimeStamp | child_name | child_version | Nullname | Key | Default | Extraversion |
+--------+-----------+------------+----+------+-----+-------------+---------+
| name NULL | NULL | varchar(120) | NOexample1 | PRI | NULL1.0.0 | ExampleList | 1.0.0 |
| version NULL | varchar(20) NULL | NOexample2 | PRI | NULL1.0.0 | ExampleList | 1.0.0 |
+--------+-----------+------------+----+------+-----+-------------+---------+
Hibernate
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjListEc_EXAMPLES;
+------------------------------+------------------------------------------------------------------------------------------------------+
| Table | Create Table Table |
+------------------------------+------------------------------------------------------------------------------------------------------------+
| JpaExampleObjListEc_EXAMPLES | CREATE TABLE `JpaExampleObjListEc_EXAMPLES` (
`name` varchar(120+
| 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` `version` varcharbit(201) DEFAULT NULL,
`EXAMPLES` longblob `timeStamp` datetime(6) DEFAULT NULL,
KEY `FK_JpaExampleObjListEc_EXAMPLES_name``FK1a58hldurq1910ne2hbm9a7af` (`name`,`version`),
CONSTRAINT `FK_JpaExampleObjListEc_EXAMPLES_name` FOREIGN KEY`FK1a58hldurq1910ne2hbm9a7af` FOREIGN KEY (`name`, `version`)
REFERENCES `ExampleObjListEc` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 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 |
+-------------+---------+------------+---------------+----------------------+-----------+
After saving an example:
...
Map of Objects using OneToMany
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Entity
@Table(name = "ExampleObjMap")
@Data
public class JpaExampleObjMap implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
@VerifyKey
@NotNull
private ExampleKey key;
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
@Lob
private Map<@NotNull String, @NotNull JpaExample> examples;
} |
Representation of the example in YAML of what we could save using JpaExampleObjMap entity.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
ExampleObjMap: name: ExampleObjMap version: 1.0.0 examples: MyKey1: name: example1 version: 1.0.0 |
...
MyKey2:
name: example2
version: 1.0.0 |
Eclipse-Link
MariaDB [controlloop]> select * from JpaExampleObjListEc_EXAMPLESdescribe ExampleObjMap;
+----------+-----+---------+------+-----+---------+-------+
| Field name | Type | version | EXAMPLESNull | Key | Default | Extra |
+----------+---+-----------+------+-----+---------+-------+
| ExampleList | 1.0.0 | .... <binary code> .... |
| ExampleList | 1.0.0 | .... <binary code> .... |
+| EXAMPLES | longblob | YES | | NULL | |
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+----------+----+----------+------+-----+---------+-------+
...
After saving the example:
MariaDB [controlloop]> select * describefrom ExampleObjListEcExampleObjMap;
+---------+--------------+---+---+-----+-------+--+-------+
| FieldEXAMPLES | Type | Nullname | Key | Default | Extraversion |
+---------+--------------+---+---+-----+-------+--+-------+
| name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+---------+--------------+------.... <binary code> .... | ExampleObjMap | 1.0.0 |
+-----+---------+-------+
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjListEc_EXAMPLES;
+-----+---------------+---------+
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 |
+---------+--------------+------+-----+---------+---------+
| Table | Create Table name | varchar(120) | NO | PRI | NULL | |
| version | varchar(20) | NO | PRI | NULL | |
+---------+--------------+------+-----+---------+-------+
MariaDB [controlloop]> SHOW CREATE TABLE ExampleObjMap_Example;
+-----------------------+--------------------------------------------------------------------------+
| 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`),
-----------------------------------+
| Table | Create Table |
+-----------------------+-------------------------------------------------------------------------------------------------------------+
| ExampleObjMap_Example | CREATE TABLE `ExampleObjMap_Example` (
CONSTRAINT `FK1a58hldurq1910ne2hbm9a7af` FOREIGN`name` KEY (`name`, `version`)
REFERENCES `ExampleObjListEc` (`name`, `version`),
varchar(120) NOT NULL,
CONSTRAINT `FKnj1lga10so090q9wf38k4jf7p` FOREIGN`version` KEY (`examples_name`, `examples_version`)
REFERENCES `Example` (`name`, `version`)varchar(20) NOT NULL,
) ENGINE=InnoDB`EXAMPLES_KEY` varchar(255) DEFAULT CHARSET=utf8mb4NULL,
PRIMARY KEY (`name`,`version`),
CONSTRAINT `FK_ExampleObjMap_Example_name` FOREIGN KEY |
+------------------------------+------------------------------------------------------------------------------------------------------+
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 |
+---(`name`, `version`)
REFERENCES `ExampleObjMap` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+----------+---------+
| 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)
...
language | java |
---|---|
title | JpaExampleObjListEc |
collapse | true |
...
+
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)
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Entity
@Table(name = "ExampleObjMap")
@Data
public class JpaExampleObjMap implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
@VerifyKey
@NotNull
private ExampleKey key;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(
joinColumns = {@JoinColumn(name = "parent_name", referencedColumnName = "name"),
@JoinColumn(name = "parent_version", referencedColumnName = "version")},
inverseJoinColumns = {@JoinColumn(name = "child_name", referencedColumnName = "name"),
@JoinColumn(name = "child_version", referencedColumnName = "version")})
private Map<@NotNull String, @NotNull JpaExample> examples;
} |
Eclipse-Link
MariaDB [controlloop]> SHOW CREATE TABLE JpaExampleObjListEcExampleObjMap_EXAMPLESExample;
+-----------------------+-------+------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------------------+-------+------------------------------------------------------------------------------------------------------+
| JpaExampleObjListEcExampleObjMap_EXAMPLESExample | CREATE TABLE `JpaExampleObjListEc`ExampleObjMap_EXAMPLES`Example` (
`parent_name` varchar(120) NOT NULL,
`PRIMED` tinyint(1) DEFAULT 0,
`parent_version` varchar(20) NOT NULL,
`timeStamp` varchar(255) DEFAULT NULL,
`child_name` varchar(120) NOT NULL,
`child_name`version` varchar(25520) DEFAULTNOT NULL,
`child`EXAMPLES_version`KEY` varchar(255) DEFAULT NULL,
PRIMARY KEY (`parent_name`,`parent_version`,`child_name`,`child_version`),
`name` varchar(120) DEFAULT NULL,
KEY `FK_ExampleObjMap_Example_child_name` (`child_name`,`child_version`),
CONSTRAINT `FK_ExampleObjMap_Example_child_name` FOREIGN KEY (`child_name`, `child_version`)
`version` varchar(20) DEFAULT NULL,
KEY `FK_JpaExampleObjListEc_EXAMPLES_name`REFERENCES `Example` (`name`, `version`),
CONSTRAINT `FK_JpaExampleObjListEcExampleObjMap_Example_EXAMPLESparent_name` FOREIGN KEY (`name``parent_name`, `version``parent_version`)
REFERENCES `ExampleObjListEc``ExampleObjMap` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+-----------------------+---------+----------------------------------------------------------------------------------------------------+
After saving the example:
MariaDB [controlloop]> select * from ExampleObjMap;
+---------------+---------+
| name | version |
+---------------+---------+
| ExampleObjMap | 1.0.0 |
+---------------+---------------------+
After saving an example:
MariaDB [controlloop]> select * from ExampleObjListEcExample;
+--------+-----------+----------+---------+
| PRIMED | timeStamp | name | version |
+--------+-----------+----------+
| ExampleList---------+
| NULL | NULL | example1 | 1.0.0 |
| NULL | NULL | example2 | 1.0.0 |
+
+--------+-----------+----------+---------+
MariaDB [controlloop]> select * from JpaExampleObjListEcExampleObjMap_EXAMPLESExample;
+--------+-------+----+------------+------------+---+------------+-----+---------+
| parent_name PRIMED | timeStampparent_version | child_name | child_version | name | version |EXAMPLES_KEY |
+--------+-------+----+------------+------------+------+---------+-----+---------+
| ExampleObjMap NULL | NULL| 1.0.0 | example1 | 1.0.0 | MyKey1 |
| ExampleListExampleObjMap | 1.0.0 |
| NULL | NULL | example2 | 1.0.0 | ExampleListMyKey2 | 1.0.0 |
+--------+-------+----+------------+------------+---+------------+-----+---------+
Hibernate
MariaDB
...
[controlloop]>
...
SHOW
...
CREATE
...
TABLE
...
ExampleObjMap_
...
Example;
+-----------------------+-------+------------------------------------------------------------------------------------------------------+
| Table | Create Table | Create Table |
+-----------------------+-------+------------------------------------------------------------------------------------------------------+
| JpaExampleObjListEc_EXAMPLES | CREATE TABLE `JpaExampleObjListEc_EXAMPLES` (
| ExampleObjMap_Example | CREATE TABLE `ExampleObjMap_Example` (
`parent_name` varchar(120) NOT NULL,
`name``parent_version` varchar(12020) NOT NULL,
`child_name` varchar(120) NOT NULL,
`version` `child_version` varchar(20) NOT NULL,
`child_name` `examples_KEY` varchar(255) DEFAULTNOT NULL,
PRIMARY `child_version` varchar(255) DEFAULT NULLKEY (`parent_name`,`parent_version`,`examples_KEY`),
UNIQUE KEY `primed` bit(1) DEFAULT NULL,
`UK_ma8t20i58tt5ilqjrk2ged242` (`child_name`,`child_version`),
CONSTRAINT `FK2n1x5g38x55wejkvnvhqin980` FOREIGN KEY (`parent_name`, `parent_version`)
`timeStamp` datetime(6) DEFAULT NULL,
KEYREFERENCES `FK1a58hldurq1910ne2hbm9a7af``ExampleObjMap` (`name`, `version`),
CONSTRAINT `FK1a58hldurq1910ne2hbm9a7af``FKstwyuf69lrj4tjpafwriuwp3h` FOREIGN KEY (`name``child_name`, `version``child_version`)
REFERENCES `ExampleObjListEc``Example` (`name`, `version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+-----------------------+-------+------------------------------------------------------------------------------------------------------+
After saving an the example:
MariaDB [controlloop]> select * from ExampleObjListEc;
ExampleObjMap;
+---------------+---------+
| name | version |
+---------------+---------+
| ExampleObjMap | 1.0.0 |
+---------------+---------+
MariaDB [controlloop]> select * from Example;
+----------+---------+--------+-----------+
| name | version | primed | versiontimeStamp |
+----------+---------+--------+-----------+
| ExampleList| example1 | 1.0.0 | NULL | NULL |
| example2 | 1.0.0 | NULL | NULL |
+----------+---------+--------+-----------+
MariaDB [controlloop]> select * from JpaExampleObjListEcExampleObjMap_EXAMPLESExample;
+---------------+---------+-------+-------+-----+----------+-----+---+-----------+
| parent_name | parent_version | child_name | child_version | primed | timeStampexamples_KEY |
+---------------+---------+-------+-------+-----+----------+-----+---+-----------+
| ExampleListExampleObjMap | 1.0.0 | example1 | 1.0.0 | NULLMyKey1 | NULL |
| ExampleListExampleObjMap | 1.0.0 | example2 | 1.0.0 | NULLMyKey2 | NULL |
+---------------+----------+------+------+------+----------+-----+---+-----------+