Skip to content

Commit

Permalink
Add contextAttrs api for SqlEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
HidekiSugimoto189 committed Oct 28, 2024
1 parent 6f8a78d commit d944d5c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,16 @@ public T where(final CharSequence rawString, final Map<String, Object> paramMap)
return (T) this;
}

/**
* {@inheritDoc}
*
* @see jp.co.future.uroborosql.fluent.ExtractionCondition#contextAttrs()
*/
@Override
public Map<String, Object> contextAttrs() {
return context().contextAttrs();
}

/**
* 条件指定用のラップクラス
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,10 @@ public interface ExtractionCondition<T> {
*/
T where(CharSequence rawString, Map<String, Object> paramMap);

/**
* ExecutionContextが保持する属性を取得する
* @return ExecutionContext属性情報
*/
Map<String, Object> contextAttrs();

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,11 @@ void testDeleteThrowException() {
});
}

@Test
void testContextAttrs() {
var delete = agent.delete(Product.class);
delete.contextAttrs().put("dummyValue", Integer.MAX_VALUE);
assertThat(delete.contextAttrs().get("dummyValue"), is(Integer.MAX_VALUE));
}

}
7 changes: 7 additions & 0 deletions src/test/java/jp/co/future/uroborosql/SqlEntityQueryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,11 @@ void testOptimizerHints() {
assertThat(products.size(), is(2));
}

@Test
void testContextAttrs() {
var query = agent.query(Product.class);
query.contextAttrs().put("dummyValue", Integer.MAX_VALUE);
assertThat(query.contextAttrs().get("dummyValue"), is(Integer.MAX_VALUE));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,13 @@ void testEntityUpdateWithId() throws Exception {
});
}

@Test
void testContextAttrs() {
var update = agent.update(TestEntity.class);
update.contextAttrs().put("dummyValue", Integer.MAX_VALUE);
assertThat(update.contextAttrs().get("dummyValue"), is(Integer.MAX_VALUE));
}

@Table(name = "test_entity")
public static class TestEntity {
@Id
Expand Down

0 comments on commit d944d5c

Please sign in to comment.