Skip to content

Commit

Permalink
sort detailEntities
Browse files Browse the repository at this point in the history
  • Loading branch information
getrebuild committed Nov 17, 2023
1 parent 0b293fa commit 92c7777
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>cn.devezhao</groupId>
<artifactId>persist4j</artifactId>
<version>1.7.4</version>
<version>1.7.5</version>
<packaging>jar</packaging>

<name>persist4j</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,12 @@ public Entity getMainEntity() {
@Override
public Entity getDetailEntity() {
if (detailEntities.isEmpty()) return null;

Entity useMaxCode = detailEntities.get(0);
for (Entity de : detailEntities) {
if (de.getEntityCode() > useMaxCode.getEntityCode()) useMaxCode = de;
}
return useMaxCode;
return getDetialEntities()[0];
}

@Override
public Entity[] getDetialEntities() {
if (detailEntities.isEmpty()) return null;
return detailEntities.toArray(new Entity[0]);
}

Expand Down Expand Up @@ -216,5 +212,8 @@ protected void setMainEntity(Entity mainEntity) {
((EntityImpl) mainEntity).detailEntities.clear();
}
((EntityImpl) mainEntity).detailEntities.add(this);

// Sort by code
((EntityImpl) mainEntity).detailEntities.sort((o1, o2) -> o2.getEntityCode().compareTo(o1.getEntityCode()));
}
}

0 comments on commit 92c7777

Please sign in to comment.