Changeset 9126

Show
Ignore:
Timestamp:
06/15/08 18:45:21 (4 months ago)
Author:
robert.thurnher
Message:

mainly refines Hibernate API wrapper method calls

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/blog-ng_hibernate/lib/hibernate.js

    r9125 r9126  
    8181    * plus executing the actual Hibernate session API wrapper method operations. 
    8282    */ 
    83    this.getHibernateTemplate = function (params) { 
     83   this.getHibernateTemplate = function (method, params) { 
    8484      var sess = this.getSession(); 
    8585 
    8686      // do the actual operation 
    87       switch (params.method) { 
     87      switch (method) { 
    8888         case 'save': 
    8989            sess['saveOrUpdate(java.lang.String,java.lang.Object)'](params.object._type || 
     
    112112            break; 
    113113         case 'list': 
    114             var criteria = sess['createCriteria(java.lang.String)'](params.listParams.type); 
     114            var criteria = sess['createCriteria(java.lang.String)'](params.type); 
    115115            criteria.setCacheable(true); 
    116             if (params.listParams.orderBy) { 
    117                var order = (params.listParams.order == 'asc') ? 
    118                            org.hibernate.criterion.Order.asc(params.listParams.orderBy) : 
    119                            org.hibernate.criterion.Order.desc(params.listParams.orderBy); 
     116            if (params.orderBy) { 
     117               var order = (params.order == 'asc') ? 
     118                           org.hibernate.criterion.Order.asc(params.orderBy) : 
     119                           org.hibernate.criterion.Order.desc(params.orderBy); 
    120120               criteria.addOrder(order); 
    121121            } 
    122             if (params.listParams.max && (typeof params.listParams.max == 'number')) { 
    123                criteria.setMaxResults(params.listParams.max); 
     122            if (params.max && (typeof params.max == 'number')) { 
     123               criteria.setMaxResults(params.max); 
    124124            } 
    125125 
     
    141141   this.save = function (object) { 
    142142      try { 
    143          return this.getHibernateTemplate({ method: 'save', object: object }); 
     143         return this.getHibernateTemplate('save', { object: object }); 
    144144      } catch (e) { 
    145145         log.error('in "save": ' + e.toString()); 
     
    150150   this.get = function (type, id) { 
    151151      try { 
    152          return this.getHibernateTemplate({ method: 'get', type: type, id: id }); 
     152         return this.getHibernateTemplate('get', { type: type, id: id }); 
    153153      } catch (e) { 
    154154         log.error('in "get": ' + e.toString()); 
     
    159159   this.find = function (query) { 
    160160      try { 
    161          return this.getHibernateTemplate({ method: 'find', query: query }); 
     161         return this.getHibernateTemplate('find', { query: query }); 
    162162      } catch (e) { 
    163163         log.error('in "find": ' + e.toString()); 
     
    168168   this.all = function (type) { 
    169169      try { 
    170          return this.getHibernateTemplate({ method: 'all', type: type }); 
     170         return this.getHibernateTemplate('all', { type: type }); 
    171171      } catch (e) { 
    172172         log.error('in "all": ' + e.toString()); 
     
    177177   this.remove = function (object) { 
    178178      try { 
    179          return this.getHibernateTemplate({ method: 'remove', object: object }); 
     179         return this.getHibernateTemplate('remove', { object: object }); 
    180180      } catch (e) { 
    181181         log.error('in "remove": ' + e.toString()); 
     
    186186   this.list = function (params) { 
    187187      try { 
    188          return this.getHibernateTemplate({ method: 'list', listParams: params }); 
     188         return this.getHibernateTemplate('list', params); 
    189189      } catch (e) { 
    190190         log.error('in "list": ' + e.toString());