Skip to main content

Precondition

To quickly preview Jimmer's main features, we need to provide several entities here as the basic assumption of all discussions in this section.

Status of Entities

tip

In Jimmer applications, the only thing that matters is the unified global ORM entity model.

The global entity model is finalized with the database design, irrelevant to specific query/modification business logics' requirements for interaction formats, and relatively stable.

As for what kind of DTO types each query/modification business needs to interact with, it is completely unimportant.

Only the relatively stable entity model is important. So Jimmer is good at handling changing requirements.

UML Relationships Between Entities

Here we list three entity types: BookStore, Book, Author and TreeNode, as the basic assumptions for all discussions in the current section.

uml

Entity Type Definitions

BookStore

@Entity
public interface BookStore {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
long id();

String name();

@Nullable
String website();

@OneToMany(mappedBy = "store")
List<Book> books();
}

Book

@Entity  
public interface Book {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
long id();

@Key
String name();

@Key
int edition();

BigDecimal price();

@Nullable
@ManyToOne
BookStore store();

@ManyToMany
List<Author> authors();
}

Author

@Entity  
public interface Author {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
UUID id();

@Key
String firstName();

@Key
String lastName();

Gender gender();

@ManyToMany(mappedBy = "authors")
List<Book> books();
}

Where Gender is a very simple enum type

public enum Gender { MALE, FEMALE }