mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
better detection of empty database
This commit is contained in:
@@ -28,4 +28,8 @@ public class UserDAO extends GenericDAO<User> {
|
||||
return newQuery().from(user).where(user.email.equalsIgnoreCase(email)).leftJoin(user.roles, QUserRole.userRole).fetch()
|
||||
.uniqueResult(user);
|
||||
}
|
||||
|
||||
public long count() {
|
||||
return newQuery().from(user).count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class StartupService implements Managed {
|
||||
new UnitOfWork<Void>(sessionFactory) {
|
||||
@Override
|
||||
protected Void runInSession() throws Exception {
|
||||
if (userDAO.findByName(CommaFeedApplication.USERNAME_ADMIN) == null) {
|
||||
if (userDAO.count() == 0) {
|
||||
initialData();
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user