-
Couldn't load subscription status.
- Fork 45
2단계 - Proxy #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: yangseungin
Are you sure you want to change the base?
2단계 - Proxy #125
Changes from all commits
34247f9
748d297
7fb4058
55fc069
6f7997d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ | |
| import persistence.sql.entity.EntityColumn; | ||
| import persistence.sql.entity.EntityColumns; | ||
| import persistence.sql.entity.EntityTable; | ||
| import persistence.sql.entity.OneToManyColumn; | ||
|
|
||
| import java.lang.reflect.Field; | ||
| import java.util.Arrays; | ||
|
|
@@ -30,18 +29,20 @@ private String columnsClause(EntityColumns entityColumns, Object parentEntity) { | |
| .collect(Collectors.toList()); | ||
|
|
||
| if (parentEntity != null) { | ||
| OneToManyColumn oneToManyColumn = new OneToManyColumn(findOneToManyField(parentEntity.getClass())); | ||
| columns.add(oneToManyColumn.getForeignKeyColumnName()); | ||
| List<Field> oneToManyFields = findOneToManyFields(parentEntity.getClass()); | ||
| for (Field oneToManyField : oneToManyFields) { | ||
| EntityColumn oneToManyColumn = EntityColumn.from(oneToManyField); | ||
| columns.add(oneToManyColumn.getOneToManyColumn().getForeignKeyColumnName()); | ||
| } | ||
| } | ||
|
|
||
| return String.join(", ", columns); | ||
| } | ||
|
|
||
| private Field findOneToManyField(Class<?> clazz) { | ||
| private List<Field> findOneToManyFields(Class<?> clazz) { | ||
| return Arrays.stream(clazz.getDeclaredFields()) | ||
| .filter(field -> field.isAnnotationPresent(OneToMany.class)) | ||
| .findFirst() | ||
| .orElseThrow(() -> new RuntimeException("OneToMany 필드를 찾을 수 없습니다.")); | ||
| .collect(Collectors.toList()); | ||
| } | ||
|
Comment on lines
+42
to
46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여전히 이 행위는 ParentEntity 의 metadata 로 가져와 볼 수 있지 않을까요? |
||
|
|
||
| private String valueClause(EntityColumns entityColumns, Object object, Long parentId) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,10 +86,10 @@ void insert2() throws SQLException { | |
| List<OrderItem> selectResult = jdbcTemplate.query(selectQuery, new EntityRowMapper<>(OrderItem.class)); | ||
|
|
||
| assertThat(selectResult).hasSize(2); | ||
| assertThat(selectResult.get(0).getProduct()).isEqualTo(orderItem1.getProduct()); | ||
| assertThat(selectResult.get(0).getQuantity()).isEqualTo(orderItem1.getQuantity()); | ||
| assertThat(selectResult.get(1).getProduct()).isEqualTo(orderItem2.getProduct()); | ||
| assertThat(selectResult.get(1).getQuantity()).isEqualTo(orderItem2.getQuantity()); | ||
| assertThat(selectResult.get(0).getProduct()).isEqualTo("감자"); | ||
| assertThat(selectResult.get(0).getQuantity()).isEqualTo(3); | ||
| assertThat(selectResult.get(1).getProduct()).isEqualTo("고구마"); | ||
| assertThat(selectResult.get(1).getQuantity()).isEqualTo(1); | ||
|
Comment on lines
+89
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 전 단계 피드백 반영해주셨네요 👍 |
||
|
|
||
| jdbcTemplate.execute("drop table order_items"); | ||
| jdbcTemplate.execute("drop table orders"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그럼 매번 여기서 생성 할 필요 없을 것 같아요