Skip to content

Commit 45de33b

Browse files
committed
expose PojoRepository.getId
(cherry picked from commit ca96e23)
1 parent 6b32cf9 commit 45de33b

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/main/java/com/marklogic/client/impl/PojoRepositoryImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ private void findId() {
500500
}
501501

502502
@SuppressWarnings("unchecked")
503-
private ID getId(T entity) {
503+
public ID getId(T entity) {
504504
findId();
505505
if ( idMethod != null ) {
506506
try {

src/main/java/com/marklogic/client/pojo/PojoRepository.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@
8282
* precision, use Strings to persist those numbers.
8383
*/
8484
public interface PojoRepository<T, ID extends Serializable> {
85+
/** Get the value of the id field (the field marked with the {@literal @}Id
86+
* annotation).
87+
*/
88+
public ID getId(T entity);
89+
8590
/** Write this instance to the database. Uses the field marked with {@literal @}Id
8691
* annotation to generate a unique uri for the document. Adds a collection with the
8792
* fully qualified class name. Uses a particular configuration of

src/test/java/com/marklogic/client/test/PojoFacadeTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ private void validateCity(City city) {
638638
assertNotNull("City should never be null", city);
639639
assertNotNull("GeoNamId should never be null", city.getGeoNameId());
640640
if ( "Chittagong".equals(city.getName()) ) {
641+
assertEquals("Chittagong should have id 1205733", 1205733, cities.getId(city).intValue());
641642
BulkReadWriteTest.validateChittagong(city);
642643
}
643644
}

0 commit comments

Comments
 (0)