...
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 |
+-----------------+---------+------------+---------------+--------+-----------+--------------+
Map of Objects using ElementCollection (hacked)
Using Jpa Converters, it is possible to convert Object class to binary array. In this scenario JpaExampleEmd class is not entity and neither embedded.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Data
public class JpaExampleEmd implements Serializable {
private static final long serialVersionUID = 1L;
@VerifyKey
@NotNull
private ExampleKey key;
private Boolean primed;
@NotNull
private Date timeStamp;
}
@Converter(autoApply = true)
public class ExampleConverter implements AttributeConverter<JpaExampleEmd, byte[]> {
@Override
public byte[] convertToDatabaseColumn(JpaExampleEmd attribute) {
return SerializationUtils.serialize(attribute);
}
@Override
public JpaExampleEmd convertToEntityAttribute(byte[] dbData) {
return (JpaExampleEmd) SerializationUtils.deserialize(dbData);
}
}
@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> examples;
} |
JpaToscaDataType_PROPERTIES table
...
- Move to Hibernate with EclipseLink tables is not possible due the presence of ElementCollection not used properlypossible using Jpa Converters.
- The presence of longblob types used to store whole objects is an issues, it is readable only by Java language or by any other language compatible with Java binary code. I am not sure if a db-migrator can handle that.
- Document databases store all information for a given object in a single instance in the database, and every stored object can be different from every other. So, using MongoDB/Cassandra will solve all issues.
JpaRepository
andMongoRepository
extendCrudRepository
and expose the capabilities of the underlying persistence technology in addition to the rather generic persistence technology-agnostic interfaces like e.g.CrudRepository
.
...