add system operator agent

This commit is contained in:
Sola
2015-12-12 23:45:16 +08:00
parent 19f68c1e33
commit abb8891152
6 changed files with 67 additions and 2 deletions

View File

@@ -37,6 +37,8 @@ public class SQLCore {
sr = new StandardServiceRegistryBuilder().configure().build();
sf = new MetadataSources(sr).buildMetadata().buildSessionFactory();
TableOperator.init();
} catch (Exception e) {
e.printStackTrace();
}

View File

@@ -22,5 +22,17 @@ public class TableOperator extends SQLCore {
}
}
public static Operator get(int id) {
try (Session s = SQLCore.sf.openSession()) {
return s.get(Operator.class, id);
}
}
protected static void init() {
try (Session s = SQLCore.sf.openSession()) {
Operator.USER_SELF = s.get(Operator.class, -1);
Operator.ADMIN = s.get(Operator.class, 0);
}
}
}