then you need to update code: if (userId > 0) to be if (userId != null) to avoid NPE
On Thu, Feb 7, 2013 at 1:00 PM, [email protected] <[email protected] > wrote: > Sorry I don't understand it. > Maybe there might be a misunderstanding. > > Usermanagement has now a method: > usersDao.update(user, -1L); > -1L is for me almost same random as 1L. But -1L can never exist. Null would > make sense. > > I guess it might make sense to change the update method in the > IDataProviderDao to "Long userId" instead of "long userId" so that you can > use "null" as userId. Same for the delete method in the IDataProviderDao. > That would actually solve all issue from my point of view. > > I have modified it just like that now. > > Sebastian > > > 2013/2/5 Maxim Solodovnik <[email protected]> > > > commited > > > > > > On Tue, Feb 5, 2013 at 3:55 PM, Maxim Solodovnik <[email protected] > > >wrote: > > > > > you are right :) > > > I'll update the DAOs to have anonymous updates :) > > > > > > > > > On Tue, Feb 5, 2013 at 3:50 PM, [email protected] < > > > [email protected]> wrote: > > > > > >> hehe > > >> > > >> what makes you think that > > >> > > >> public void updateUser(User user) { > > >> usersDao.update(user, 1l); > > >> } > > >> > > >> is a good idea? Why not 2L or -1L or any other random number? > > >> I mean: What makes the user with the Id 1 so important that we will by > > >> default sign up every edit action to his account? > > >> > > >> null would make sense. But the update does not allow it. Thats why > I've > > >> added one that has no userId param. > > >> When we use database generated indexes/sequencers the userId 1 could > > >> someday not exist at all. So this hardcoded 1L makes me just not happy > > :) > > >> > > >> Sebastian > > >> > > >> > > >> 2013/2/5 <[email protected]> > > >> > > >> > Author: solomax > > >> > Date: Tue Feb 5 08:40:25 2013 > > >> > New Revision: 1442500 > > >> > > > >> > URL: http://svn.apache.org/viewvc?rev=1442500&view=rev > > >> > Log: > > >> > Code clean up: Copy/pasted method was removed > > >> > > > >> > Modified: > > >> > > > >> > > > >> > > > openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/user/Usermanagement.java > > >> > > > >> > > > >> > > > openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/user/dao/UsersDao.java > > >> > > > >> > > > >> > > > openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/ldap/LdapLoginManagement.java > > >> > > > >> > Modified: > > >> > > > >> > > > openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/user/Usermanagement.java > > >> > URL: > > >> > > > >> > > > http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/user/Usermanagement.java?rev=1442500&r1=1442499&r2=1442500&view=diff > > >> > > > >> > > > >> > > > ============================================================================== > > >> > --- > > >> > > > >> > > > openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/user/Usermanagement.java > > >> > (original) > > >> > +++ > > >> > > > >> > > > openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/user/Usermanagement.java > > >> > Tue Feb 5 08:40:25 2013 > > >> > @@ -1549,7 +1549,7 @@ public class Usermanagement { > > >> > } > > >> > > > >> > public void updateUser(User user) { > > >> > - usersDao.update(user); > > >> > + usersDao.update(user, 1L); > > >> > } > > >> > > > >> > /** > > >> > > > >> > Modified: > > >> > > > >> > > > openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/user/dao/UsersDao.java > > >> > URL: > > >> > > > >> > > > http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/user/dao/UsersDao.java?rev=1442500&r1=1442499&r2=1442500&view=diff > > >> > > > >> > > > >> > > > ============================================================================== > > >> > --- > > >> > > > >> > > > openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/user/dao/UsersDao.java > > >> > (original) > > >> > +++ > > >> > > > >> > > > openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/user/dao/UsersDao.java > > >> > Tue Feb 5 08:40:25 2013 > > >> > @@ -139,17 +139,6 @@ public class UsersDao implements IDataPr > > >> > return u; > > >> > } > > >> > > > >> > - public User update(User u) { > > >> > - if (u.getUser_id() == null) { > > >> > - u.setStarttime(new Date()); > > >> > - em.persist(u); > > >> > - } else { > > >> > - u.setUpdatetime(new Date()); > > >> > - u = em.merge(u); > > >> > - } > > >> > - return u; > > >> > - } > > >> > - > > >> > public void delete(User u, long userId) { > > >> > deleteUserID(u.getUser_id()); > > >> > } > > >> > > > >> > Modified: > > >> > > > >> > > > openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/ldap/LdapLoginManagement.java > > >> > URL: > > >> > > > >> > > > http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/ldap/LdapLoginManagement.java?rev=1442500&r1=1442499&r2=1442500&view=diff > > >> > > > >> > > > >> > > > ============================================================================== > > >> > --- > > >> > > > >> > > > openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/ldap/LdapLoginManagement.java > > >> > (original) > > >> > +++ > > >> > > > >> > > > openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/ldap/LdapLoginManagement.java > > >> > Tue Feb 5 08:40:25 2013 > > >> > @@ -726,7 +726,7 @@ public class LdapLoginManagement { > > >> > > > >> > User user = usersDao.get(newUserId); > > >> > user.setPictureuri(pictureUri); > > >> > - usersDao.update(user); > > >> > + usersDao.update(user, 1L); > > >> > > > >> > } catch (Exception e) { > > >> > log.error("Error creating user : " + > > >> > e.getMessage()); > > >> > > > >> > > > >> > > > >> > > >> > > >> -- > > >> Sebastian Wagner > > >> https://twitter.com/#!/dead_lock > > >> http://www.webbase-design.de > > >> http://www.wagner-sebastian.com > > >> [email protected] > > >> > > > > > > > > > > > > -- > > > WBR > > > Maxim aka solomax > > > > > > > > > > > -- > > WBR > > Maxim aka solomax > > > > > > -- > Sebastian Wagner > https://twitter.com/#!/dead_lock > http://www.webbase-design.de > http://www.wagner-sebastian.com > [email protected] > -- WBR Maxim aka solomax
