objectbox / objectbox/objectbox-java

Embedded Objects

Open
#456 2 comments 14 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
4.6k
Forks
311
PR merge metrics
No merged PRs in 30d

Description

Hi,

I would like to store ValueObjects inside @Entity object, is it somehow supported?
What that basically mean is you can convert one class field into multiple database fields.
Solution 1)
Flatten the hierarchy

@Entity
public class Bill {
    private String priceCurrency;
    private Double priceAmount;
}

Solution 2)
Make relation

@Entity
public class Bill {
    private ToOne<Money> price;
}
@Entity
public class Money {
    @Id Long id;
    private String currency;
    private Double amount;
}

Solution 3)
Convert to one database field

@Entity
public class Bill {
    @Convert(converter = MoneyConverter.class,dbType = String.class)
    private Money money;
}

Neither of those solutions fit all my requirements which are

  1. Do not map manually between multiple class fields and ValueObject
  2. Do not use relation for performance/convenience reason
  3. Sum and compare ValueObjects fields such as Double amount

Somebody have solution to this?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name any source files, tests, or entry points. Start by locating the entity-mapping and value-conversion code, then determine whether embedded value objects can meet the stated requirements without manual field mapping, relations, or single-field conversion; done requires a documented, tested supported approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.