为了让类的对象间可以排序,通常有两种方法——Comparable 与 Comparator。
Comparable泛型接口
int java.lang.Comparable.compareTo(T o)
本对象与参数进行对比。返回为负表示小于,零表示相等,正数表示大于。
Compares this object with the specified object for order. Re...
分类:
其他好文 时间:
2015-02-03 19:26:02
阅读次数:
143
string[] gqds_key = new string[23]; string[] gqds_table = new string[23]; string[] gqds_where = new string[23]; string[] gqds_order = new string[23]; ...
分类:
其他好文 时间:
2015-02-03 19:13:41
阅读次数:
143
优化前代码select *,ROW_NUMBER() OVER(order by WrongCount desc) as rowIdfrom(select Quba_IDint,Quba_Number, (select top 1 Sqre_AddDateT...
分类:
数据库 时间:
2015-02-03 18:48:57
阅读次数:
178
select * from (select rownum,KEYWORD, CATEGORY,CREATE_DATE,UPDATE_DATE from (select * from knet_keyword_category_t where category='two') order by dbms...
分类:
数据库 时间:
2015-02-03 18:44:27
阅读次数:
174
经过博文之一和之二的重构,貌似代码表现的还不错,正常运行和test都通过鸟,但是,感觉告诉我们还是有什么地方不对劲啊!究竟是哪里不对劲呢?我们再来好好看一下.
我们把数据库表中的支付方式集合直接放在实现的地方,貌似很唐突.无论是Order model中,Order控制器中还是new.html.erb中都是如此:
#in Order.rb
validates :pay_type...
分类:
数据库 时间:
2015-02-03 17:27:32
阅读次数:
131
怎么还有啊!别急,有强迫症的人伤不起!有点小事没说完感觉痒痒的:就是如果表payment_types经常变动该怎么办?每次都要关闭rails网页服务器,然后重启吗?那也太麻烦鸟,最终的解决方案是,在Order的验证中强制每次都从数据库的表中拉取支付类型数据比较,最后修改完的Order.rb代码如下:
class Order < ActiveRecord::Base
has_many :lin...
分类:
数据库 时间:
2015-02-03 17:21:44
阅读次数:
203
默认作用域,自动加载:default_scope { order(created_at: :desc) }model 调用 find_2时才运行scope :find_2, ->{ where('clients.id' => 2 ) }下面都需要传参,使用model.find_2(id)调用scop...
分类:
其他好文 时间:
2015-02-03 17:07:24
阅读次数:
171
(8)SELECT (9)DISTINCT (11) (1)FROM [left_table](3) JOIN (2) ON (4)WHERE (5)GROUP BY (6)WITH (7)HAVING (10)ORDER BY
分类:
数据库 时间:
2015-02-03 14:39:11
阅读次数:
131
问题是这样:原来代码.html.erb页面中有一个select元素,其每个item对应的是model中的类常量:
类中的常量定义如下:
class Order < ActiveRecord::Base
PAYMENT_TYPES = ["Check","Credit card","Purchase order"]
end
现在想把PAYMENT_TYPES重构至数据库中的表里去,于...
分类:
数据库 时间:
2015-02-03 11:05:10
阅读次数:
186
【题目】
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.
Here, we will use the...
分类:
其他好文 时间:
2015-02-03 09:29:30
阅读次数:
118