- protected int insert() {
- synchronized (User.class) {
- if (id != 0) {
- throw new Error("refusing to insert");
- }
- GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("INSERT INTO certOwners() VALUES()");
- ps.execute();
- id = ps.lastInsertId();
- myCache.put(this);
- }
-
- return id;
- }
-
- public EmailAddress[] getEmails() {
- GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT id FROM emails WHERE memid=? AND deleted is NULL");
- ps.setInt(1, getId());
-
- try (GigiResultSet rs = ps.executeQuery()) {
- LinkedList<EmailAddress> data = new LinkedList<EmailAddress>();
-
- while (rs.next()) {
- data.add(EmailAddress.getById(rs.getInt(1)));
- }
-
- return data.toArray(new EmailAddress[0]);
- }
- }
-