/hostadmiral/trunk/conf/hibernate.cfg.xml.sample |
---|
17,8 → 17,5 |
<property name="show_sql">false</property> |
<mapping resource="ak/hostadmiral/util/DatabaseVersion.hbm.xml"/> |
<mapping resource="ak/hostadmiral/core/model/User.hbm.xml"/> |
<mapping resource="ak/hostadmiral/core/model/UserLogin.hbm.xml"/> |
<mapping resource="ak/hostadmiral/core/model/PasswordStoreAbstract.hbm.xml"/> |
</session-factory> |
</hibernate-configuration> |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/SystemUserManager.java |
---|
136,7 → 136,8 |
{ |
try { |
List list = HibernateUtil.currentSession().find( |
"from SystemUser where name=?", name, Hibernate.STRING); |
"select u from SystemUser u left join fetch u.owner where u.name=?", |
name, Hibernate.STRING); |
if(list.size() == 0) |
return null; |
154,7 → 155,8 |
{ |
try { |
List list = HibernateUtil.currentSession().find( |
"from SystemUser where uid=?", uid, Hibernate.INTEGER); |
"select u from SystemUser u left join fetch u.owner where u.uid=?", |
uid, Hibernate.INTEGER); |
if(list.size() == 0) |
return null; |
304,7 → 306,8 |
{ |
try { |
if(editor.isSuperuser()) { |
return HibernateUtil.currentSession().find("from SystemUser"); |
return HibernateUtil.currentSession().find( |
"select u from SystemUser u left join fetch u.owner"); |
} |
else { |
return HibernateUtil.currentSession().find( |
342,7 → 345,7 |
try { |
systemUsers = HibernateUtil.currentSession().find( |
"from SystemUser where owner = ?", |
"select u from SystemUser u where u.owner = ?", |
user, Hibernate.entity(User.class) ); |
} |
catch(HibernateException ex) |
376,7 → 379,7 |
try { |
systemUsers = HibernateUtil.currentSession().find( |
"from SystemUser where owner = ?", |
"select u from SystemUser u where u.owner = ?", |
user, Hibernate.entity(User.class) ); |
} |
catch(HibernateException ex) |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAliasManager.java |
---|
125,7 → 125,8 |
{ |
try { |
List list = HibernateUtil.currentSession().find( |
"from MailAlias where name=?", name, Hibernate.STRING); |
"select a from MailAlias a left join fetch a.domain" |
+ " left join fetch a.owner where a.name=?", name, Hibernate.STRING); |
if(list.size() == 0) |
return null; |
275,8 → 276,11 |
{ |
try { |
if(editor.isSuperuser()) |
return HibernateUtil.currentSession().find("from MailAlias"); |
return HibernateUtil.currentSession().find( |
"select a from MailAlias a left join fetch a.domain as d" |
+ " left join fetch a.owner"); |
else |
// FIXME: any problems for big lists or by pages? |
return CollectionUtils.addUnique( |
HibernateUtil.currentSession().find( |
"select a from MailAlias a left join fetch a.domain as d" |
326,7 → 330,7 |
try { |
mailAliases = HibernateUtil.currentSession().find( |
"from MailAlias where owner = ?", |
"select a from MailAlias a left join fetch a.domain where a.owner = ?", |
user, Hibernate.entity(User.class) ); |
} |
catch(HibernateException ex) |
344,7 → 348,7 |
try { |
mailAliases = HibernateUtil.currentSession().find( |
"from MailAlias where owner = ?", |
"select a from MailAlias a left join fetch a.domain where a.owner = ?", |
user, Hibernate.entity(User.class) ); |
} |
catch(HibernateException ex) |
364,7 → 368,7 |
try { |
mailAliases = HibernateUtil.currentSession().find( |
"from MailAlias where domain = ?", |
"select a from MailAlias a left join fetch a.owner where a.domain = ?", |
domain, Hibernate.entity(InetDomain.class) ); |
} |
catch(HibernateException ex) |
382,7 → 386,7 |
try { |
mailAliases = HibernateUtil.currentSession().find( |
"from MailAlias where domain = ?", |
"select a from MailAlias a left join fetch a.owner where a.domain = ?", |
domain, Hibernate.entity(InetDomain.class) ); |
} |
catch(HibernateException ex) |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAliasDestinationManager.java |
---|
109,7 → 109,7 |
{ |
try { |
return HibernateUtil.currentSession().find( |
"from MailAliasDestination where alias=?", |
"select d from MailAliasDestination d left join fetch d.mailbox where d.alias=?", |
alias, Hibernate.entity(MailAlias.class)); |
} |
catch(HibernateException ex) |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/UserManager.java |
---|
27,12 → 27,12 |
registered = true; |
try { |
/* FIMXE: do the same for all classes |
HibernateUtil.getConfiguration().addResource( |
"ak/hostadmiral/core/model/User.hbm.xml"); |
HibernateUtil.getConfiguration().addResource( |
"ak/hostadmiral/core/model/UserLogin.hbm.xml"); |
*/ |
HibernateUtil.getConfiguration().addResource( |
"ak/hostadmiral/core/model/PasswordStoreAbstract.hbm.xml"); |
userManager = new UserManager(); |
} |
catch(Exception ex) { |
128,7 → 128,7 |
{ |
try { |
List list = HibernateUtil.currentSession().find( |
"from User where login = ? and enabled = ?", |
"select u from User u left join fetch u.boss where u.login = ? and u.enabled = ?", |
new Object[] { login, Boolean.TRUE }, |
new Type[] { Hibernate.STRING, Hibernate.BOOLEAN } ); |
288,11 → 288,12 |
{ |
try { |
if(editor.isSuperuser()) { |
return HibernateUtil.currentSession().find("from User"); |
return HibernateUtil.currentSession().find( |
"select u from User u left join fetch u.boss"); |
} |
else { |
return HibernateUtil.currentSession().find( |
"from User u where u = ? or u.boss = ?", |
"select u from User u where u = ? or u.boss = ?", |
new Object[] { editor, editor}, |
new Type[] { Hibernate.entity(User.class), Hibernate.entity(User.class) } ); |
} |
310,6 → 311,7 |
return true; |
} |
else { |
// FIXME: always true? |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from User u where u = ? or u.boss = ?", |
new Object[] { editor, editor}, |
357,7 → 359,7 |
try { |
return HibernateUtil.currentSession().find( |
"from UserLogin where success = ?", |
"select l from UserLogin l left join fetch l.user where l.success = ?", |
Boolean.FALSE, Hibernate.BOOLEAN); |
} |
catch(HibernateException ex) { |
372,7 → 374,7 |
try { |
subusers = HibernateUtil.currentSession().find( |
"from User where boss = ?", |
"select u from User u where u.boss = ?", |
user, Hibernate.entity(User.class) ); |
} |
catch(HibernateException ex) { |
405,7 → 407,7 |
try { |
subusers = HibernateUtil.currentSession().find( |
"from User where boss = ?", |
"select u from User u where u.boss = ?", |
user, Hibernate.entity(User.class) ); |
} |
catch(HibernateException ex) { |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/InetDomainManager.java |
---|
116,7 → 116,8 |
{ |
try { |
List list = HibernateUtil.currentSession().find( |
"from InetDomain where name=?", name, Hibernate.STRING); |
"select d from InetDomain d left join fetch d.owner where d.name=?", |
name, Hibernate.STRING); |
if(list.size() == 0) |
return null; |
271,7 → 272,7 |
"select d from InetDomain d left join fetch d.owner"); |
else |
return HibernateUtil.currentSession().find( |
"select d from InetDomain d left join fetch d.owner where d.owner=?", |
"select d from InetDomain d where d.owner=?", |
editor, Hibernate.entity(User.class)); |
} |
catch(HibernateException ex) |
304,7 → 305,7 |
try { |
domains = HibernateUtil.currentSession().find( |
"from InetDomain where owner = ?", |
"select d from InetDomain d where d.owner = ?", |
user, Hibernate.entity(User.class) ); |
} |
catch(HibernateException ex) |
338,7 → 339,7 |
try { |
domains = HibernateUtil.currentSession().find( |
"from InetDomain where owner = ?", |
"select d from InetDomain d where d.owner = ?", |
user, Hibernate.entity(User.class) ); |
} |
catch(HibernateException ex) |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailboxManager.java |
---|
133,7 → 133,9 |
{ |
try { |
List list = HibernateUtil.currentSession().find( |
"from Mailbox where login=?", login, Hibernate.STRING); |
"select mb from Mailbox mb left join fetch mb.domain as d" |
+ " left join fetch mb.owner where mb.login=?", |
login, Hibernate.STRING); |
if(list.size() == 0) |
return null; |
337,7 → 339,7 |
try { |
mailboxes = HibernateUtil.currentSession().find( |
"from Mailbox where owner = ?", |
"select mb from Mailbox mb left join fetch mb.domain where mb.owner = ?", |
user, Hibernate.entity(User.class) ); |
} |
catch(HibernateException ex) |
355,7 → 357,7 |
try { |
mailboxes = HibernateUtil.currentSession().find( |
"from Mailbox where owner = ?", |
"select mb from Mailbox mb left join fetch mb.domain where mb.owner = ?", |
user, Hibernate.entity(User.class) ); |
} |
catch(HibernateException ex) |
375,7 → 377,7 |
try { |
mailboxes = HibernateUtil.currentSession().find( |
"from Mailbox where domain = ?", |
"select mb from Mailbox mb left join fetch mb.owner where mb.domain = ?", |
domain, Hibernate.entity(InetDomain.class) ); |
} |
catch(HibernateException ex) |
393,7 → 395,7 |
try { |
mailboxes = HibernateUtil.currentSession().find( |
"from Mailbox where domain = ?", |
"select mb from Mailbox mb left join fetch mb.owner where mb.domain = ?", |
domain, Hibernate.entity(InetDomain.class) ); |
} |
catch(HibernateException ex) |
413,7 → 415,8 |
try { |
mailboxes = HibernateUtil.currentSession().find( |
"from Mailbox where systemUser = ?", |
"select mb from Mailbox mb left join fetch mb.domain as d" |
+ " left join fetch mb.owner where mb.systemUser = ?", |
user, Hibernate.entity(SystemUser.class) ); |
} |
catch(HibernateException ex) |
431,7 → 434,8 |
try { |
mailboxes = HibernateUtil.currentSession().find( |
"from Mailbox where systemUser = ?", |
"select mb from Mailbox mb left join fetch mb.domain as d" |
+ " left join fetch mb.owner where mb.systemUser = ?", |
user, Hibernate.entity(SystemUser.class) ); |
} |
catch(HibernateException ex) |