X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=security%2Fimpl%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fusermgt%2Fjpa%2FJpaGroupSet.java;fp=security%2Fimpl%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fusermgt%2Fjpa%2FJpaGroupSet.java;h=b9db23975f748f71e3124eb7a45b5d4c8a18bd7b;hb=892308472780286f05a3f373cbc11f6f2a32a811;hp=763fced4e464512ef6e927cecfb93be7785651ec;hpb=fa0390b1f4d5f90d6c9f5ff5bd23c5206d526553;p=utils diff --git a/security/impl/src/main/java/org/wamblee/usermgt/jpa/JpaGroupSet.java b/security/impl/src/main/java/org/wamblee/usermgt/jpa/JpaGroupSet.java index 763fced4..b9db2397 100644 --- a/security/impl/src/main/java/org/wamblee/usermgt/jpa/JpaGroupSet.java +++ b/security/impl/src/main/java/org/wamblee/usermgt/jpa/JpaGroupSet.java @@ -12,10 +12,10 @@ import org.wamblee.usermgt.Group; import org.wamblee.usermgt.GroupSet; public class JpaGroupSet implements GroupSet { - - private EntityManager em; - - public JpaGroupSet(EntityManager aEm) { + + private EntityManager em; + + public JpaGroupSet(EntityManager aEm) { em = aEm; } @@ -31,12 +31,13 @@ public class JpaGroupSet implements GroupSet { @Override public boolean contains(Group aGroup) { - return find(aGroup.getName()) != null; + return find(aGroup.getName()) != null; } @Override public Group find(String aName) { - TypedQuery query = em.createNamedQuery(Group.QUERY_FIND_BY_NAME, Group.class); + TypedQuery query = em.createNamedQuery(Group.QUERY_FIND_BY_NAME, + Group.class); query.setParameter(Group.NAME_PARAM, aName); List groups = query.getResultList(); if (groups.size() > 1) { @@ -54,25 +55,28 @@ public class JpaGroupSet implements GroupSet { public void groupModified(Group aGroup) { assert aGroup.getPrimaryKey() != null; Group merged = em.merge(aGroup); - // Need to flush so that version of the merged instance is updated so we can use - // the updated version in the original group passed in. That allows the same - // group object to continue to be used as a detached object. + // Need to flush so that version of the merged instance is updated so we + // can use + // the updated version in the original group passed in. That allows the + // same + // group object to continue to be used as a detached object. em.flush(); JpaMergeSupport.merge(merged, aGroup); } @Override public Set list() { - List groups = em.createNamedQuery(Group.QUERY_ALL_GROUPS, Group.class).getResultList(); + List groups = em.createNamedQuery(Group.QUERY_ALL_GROUPS, + Group.class).getResultList(); Set res = new TreeSet(groups); - return res; + return res; } @Override public boolean remove(Group aGroup) { Group group = find(aGroup.getName()); - if ( group == null ) { - return false; + if (group == null) { + return false; } em.remove(group); return true; @@ -80,7 +84,8 @@ public class JpaGroupSet implements GroupSet { @Override public int size() { - Long res = (Long)em.createNamedQuery(Group.QUERY_COUNT_GROUPS).getSingleResult(); + Long res = (Long) em.createNamedQuery(Group.QUERY_COUNT_GROUPS) + .getSingleResult(); return res.intValue(); } }