db.collectionName.find()
> work
db.collectionName.renameCollection("1")
> operation ok
db.1.find()
> error, illegal collection name
How to rollback?
db.getCollection("1").find()
> work
db.getCollection("1").renameCollection("properCollectionName")
> done
http://blog.onetechnical.com/2013/05/22/how-to-drop-a-mongodb-collection-with-an-illegal-name/
2015年1月26日 星期一
2015年1月22日 星期四
[Java Groovy] Convert Array or Object to String
def numbers = [0, 1, 2, 3, 4, 5] as Integer[]
assert '0 x 1 x 2 x 3 x 4 x 5' == numbers.join(' x ')
def objects = [new URL('http://www.mrhaki.com'), 'mrhaki', new Expando(name: 'mrhaki'), new Date(109, 10, 10)]
assert 'http://www.mrhaki.com,mrhaki,{name=mrhaki},Tue Nov 10 00:00:00 UTC 2009' == objects.join(',')
http://mrhaki.blogspot.hk/2009/10/groovy-goodness-join-elements-to-string.html
2015年1月15日 星期四
2015年1月14日 星期三
[Spring] [MongoDB] MongoDB Collection Event Listener
Event Listeners:
How to Use:
http://www.27programs.com/2013/10/27/mongodb-collection-event-listeners-spring-data/
http://maciejwalkowiak.pl/blog/2012/05/09/sorting-spring-data-mongodb-collections-using-orderby/
http://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/core/mapping/event/AbstractMongoEventListener.html
- onBeforeConvert(E document)
- onAfterConvert(DbObject dbo, E document)
- onBeforeSave(E document)
- onAfterSave( E collection, DbObject dbo)
- ...
How to Use:
Step 1: Write Java class
package com.tsp.event;
import javax.annotation.Resource;
import org.springframework.data.mongodb.core.mapping.event.
AbstractMongoEventListener; // line broken for rendering
import com.mongodb.DBObject;
/**
* @author siva mondi
*
*/
public class UserEventListener extends AbstractMongoEventListener<User> {
@Override
public void onBeforeConvert(User user) {
}
@Override
public void onBeforeSave(User user, DBObject dbo) {
}
@Override
public void onAfterSave(User user, DBObject dbo) {
}
@Override
public void onAfterLoad(DBObject dbo) {
}
@Override
public void onAfterConvert(DBObject dbo, User user) {
}
}
|
Step 2: Register Event Listener in Spring XML
<!-- All The Event Listeners -->
<bean class="com.tsp.event.UserEventListener" />
|
http://www.27programs.com/2013/10/27/mongodb-collection-event-listeners-spring-data/
http://maciejwalkowiak.pl/blog/2012/05/09/sorting-spring-data-mongodb-collections-using-orderby/
http://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/core/mapping/event/AbstractMongoEventListener.html
[MongoDB] ObjectId to Timestamp Converter
Test data (ObjectId): 54b37110f441a40ce4239497
Return (ISO Timestamp): 2015-01-12T07:00:32.000Z
* Note that _id stores the timestamp to second only, no millisecond value stored :(
http://steveridout.github.io/mongo-object-time/
Return (ISO Timestamp): 2015-01-12T07:00:32.000Z
* Note that _id stores the timestamp to second only, no millisecond value stored :(
http://steveridout.github.io/mongo-object-time/
[JPA] @transient
transient : passing with time; remaining in a place only a brief of time
http://www.thefreedictionary.com/transient
@transient : a field not to be persisted in database
http://stackoverflow.com/questions/2154622/why-does-jpa-have-a-transient-annotation
http://www.thefreedictionary.com/transient
@transient : a field not to be persisted in database
http://stackoverflow.com/questions/2154622/why-does-jpa-have-a-transient-annotation
2015年1月13日 星期二
[Java] HashMap, TreeMap and LinkedHashMap
HashMap - random ordering, after each new insertion
TreeMap - natural ordering by key
LinkedHashMap - ordering by insertion order
http://stackoverflow.com/questions/2889777/difference-between-hashmap-linkedhashmap-and-treemap
TreeMap - natural ordering by key
LinkedHashMap - ordering by insertion order
http://stackoverflow.com/questions/2889777/difference-between-hashmap-linkedhashmap-and-treemap
訂閱:
文章 (Atom)
Weight Loss! The journey continues
是一個漫長的奮鬥旅程…… 最近嘗試努力改變的生活習慣: 晚上九時半去瞓覺 瞓覺前唔用電子奶咀,即喺ipad同手提電話(因為呢家部電話用耐咗,會無電要叉過夜) 用蔬果代替日常零食,例子有:車厘茄、藍莓、士多啤梨、粟米芯、提子,都係細細地嘅一舊一舊comp食啲 唔食熱氣零食 安靜去每...
-
裝水喉要用銅喉, 不要鐵喉, 熱水冷水都是。 裝煤氣喉因化學原理要用特製鐵喉, 不能用銅喉。如果是用煤氣熱水爐, 就要搵煤氣公司整。 用煤氣熱水爐拆要找煤氣公司, 清拆費$165公價, 安裝費一般無特別改位公價$475, 如煤氣公司check到有漏氣, 要換喉, 可在牆外...
-
Wow, 又一突破,自己換水龍頭 話說尋晚搭完飛機返到香港,第一時間拎曬行李喼d衫出黎洗,執好d野後,想沖埋涼一機過洗曬d衫,但唔知係咪去完旅行太興奮,開完個水龍頭之後點關都關唔到,感覺到裏面有d野斷左/鬆左/甩左咁,唯有沖完涼即刻放個花灑落水桶度,即刻拿拿淋去關水制。。。我...
-
8 January 2012 at 15:16 前言 話說12月左右, 考試前幾日開始左下面隻智慧齒異常的痛, D牙肉好腫, 所以去左POLY睇牙。之前E生都話過我隻智慧齒斜生, 頂住前面隻牙, 一來容易SIP食物, 2來可能影響前面隻牙會蛀, 所以叫我最好...
-
What is Interceptor? http://viralpatel.net/blogs/spring-mvc-interceptor-example/ Add autowired interceptors from Java Config http://stac...
-
Source: http://www.hket.com/eti/article/913472db-26f6-465a-b643-c5daaba82f4b-406134?category=green_news&source=print&printable=tru...