|
|
|
|
@ -109,10 +109,25 @@ public class Island { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Island findByUuid(String uuid) { |
|
|
|
|
try { |
|
|
|
|
return DaoRegistry.getIslandDao().queryBuilder().where().eq("uuid", uuid).queryForFirst(); |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void save(){ |
|
|
|
|
try { |
|
|
|
|
// createOrUpdate works by primary id; resolve id from uuid first to avoid duplicate inserts.
|
|
|
|
|
if (this.id <= 0 && this.uuid != null) { |
|
|
|
|
Island existing = findByUuid(this.uuid); |
|
|
|
|
if (existing != null) { |
|
|
|
|
this.id = existing.id; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
DaoRegistry.getIslandDao().createOrUpdate(this); |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
|