devastool / devastool/entity2jooq

Mapping entity to record(Embedded)

Open
#51 0 comments 0 reactions 1 assignee Claimed by @Sergio-Konovalov View on GitHub
enhancement release-1.0.0
Dominant language
Java
Stars
5
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Blocked by https://github.com/devastool/entity2jooq/issues/46

Need to realize mapping functionality for embedded objects.
Code generation into [generateTableClassFooter](https://github.com/devastool/entity2jooq/blob/7162c1f5e465f1c0d905b6e9d735126992e365f5/entity2jooq-codegen/src/main/java/io/github/devastool/entity2jooq/codegen/Entity2JooqJavaGenerator.java#L55)

Entity definition:
```java
@Table
public class TestEntity {
@Embedded
private Info info;

public TestEntity() {}

public Integer getInfo() {...}
public void setInfo(Info info) {...}
}
```

Generated:
```java
public Collection> toRecord(TestEntity entity) {
List> record = new ArrayList<>();
record.add(DSL.val(entity.getInfo().getId()));
return record;
}
```

Example:
```java
TestEntity entity = new TestEntity();
entity.setInfo(new Info(...));

context
.insertInto(TEST_ENTITY)
.columns(TEST_ENTITY.ID)
.values(TEST_ENTITY.toRecord(entity))
.execute();
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.