1

I've an application which stores entites in MariaDB. The entity has some relations to other entities and in one of the child entities is a binary attribute. See the following:

Parent
\ 1-n ChildA
  - attrA1
  - ...
  \ 1-n ChildB
    - attrB1
    - binaryAttr

Storing the binary files in the DB has an impact on the DB size of course and thereby an impact on our backup concept. Besides this binary data doesn't necessarily have to be in the DB as well.

I'm thinking about combining MariaDB with an S3 compatible object store, so that the structured data is persisted in DB and the binary files in the object store.

We're are using Spring Boot (Data-JPA) with Apache Camel.

The naïve approach would be to store the binary file with a uuid-key in the object store and afterwards persisting the rest of the entity with the reference (uuid) to the DB. But there's no easy transaction handling for this, nor a transparent handling of the entity (I've to handle persisting entity and binary data seperately).

  • Is there a java / spring based framework to overcome the drawbacks (transaction handling, transparent handling) of two different "datasources"?
  • What is the best practice to handle such a scenario or is it totally unrecommended?
  • Is there an extension mechanism for Spring / Hibernate to handle object store persistency within the hibernate orm mapping process?
  • Is it possible to implement one repository for persisting / loading entity and binary data at once?

Can anyone give me some direction?

  • 1. https://docs.spring.io/spring-framework/docs/current/reference/html/data-access.html#transaction – xerx593 Sep 09 '22 at 11:24
  • 2. https://mmafrar.medium.com/integrating-your-spring-boot-project-with-amazon-s3-ea3453af7fa0 (easy-peasy) – xerx593 Sep 09 '22 at 11:26
  • Combining with 3. https://dzone.com/articles/transaction-synchronization-and-spring-application / "transaction synchronization" (therefore also 1.) – xerx593 Sep 09 '22 at 11:28
  • Then you just have to decide, what/when to rollback.. – xerx593 Sep 09 '22 at 11:29
  • So: -yes,-I like!-yes, see links(1.,3.),-yes, but let's call it though service. And Since it sounds, like you're already having binaries in your "maria", you have to keep the/a smooth portation in mind. – xerx593 Sep 09 '22 at 12:02

0 Answers0