目录:
- 主索引(Primary Indexes)的应用
- 第二索引(Secondary Indexes)的应用
[一]、主索引(Primary Indexes)的应用
持久化对象的代码:UserInfo4DPL.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
package com.micmiu.berkeley.demo.vo; import java.io.Serializable; import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.PrimaryKey; @Entity public class UserInfo4DPL implements Serializable { /** * serialVersionUID */ private static final long serialVersionUID = 8709430383078839509L; @PrimaryKey private String userId; private String userName; private String description; public UserInfo4DPL() { } public UserInfo4DPL(String userId, String userName, String description) { this.userId = userId; this.userName = userName; this.description = description; } public String getUserId() { return userId; } public String getUserName() { return userName; } public String getDescription() { return description; } public void setUserId(String userId) { this.userId = userId; } public void setUserName(String userName) { this.userName = userName; } public void setDescription(String description) { this.description = description; } @Override public String toString() { return "UserInfo4DPL [userId=" + userId + ", userName=" + userName + ", description=" + description + "]"; } } |
读取操作的演示代码:DPLPrimaryIndexsDemo.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
package com.micmiu.berkeley.demo; import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import com.micmiu.berkeley.demo.vo.UserInfo4DPL; import com.sleepycat.je.Environment; import com.sleepycat.je.EnvironmentConfig; import com.sleepycat.persist.EntityCursor; import com.sleepycat.persist.EntityStore; import com.sleepycat.persist.PrimaryIndex; import com.sleepycat.persist.StoreConfig; /** * * @author <a href="http://www.micmiu.com">Michael Sun</a> */ public class DPLPrimaryIndexsDemo { /** * 演示数据存储 * * @param envHomePath */ public void testDPLPkeyPut(String envHomePath, String storeName) { Environment mydbEnv = null; EntityStore store = null; try { EnvironmentConfig envCfg = new EnvironmentConfig(); envCfg.setAllowCreate(true); envCfg.setTransactional(true); mydbEnv = new Environment(new File(envHomePath), envCfg); StoreConfig storeConfig = new StoreConfig(); storeConfig.setAllowCreate(true); storeConfig.setTransactional(true); store = new EntityStore(mydbEnv, storeName, storeConfig); System.out.println(" ---- > put data by PrimaryIndex ..."); PrimaryIndex<String, UserInfo4DPL> pIndex = store.getPrimaryIndex( String.class, UserInfo4DPL.class); List<UserInfo4DPL> list = initObject(); for (UserInfo4DPL vo : list) { System.out.println("put object:\n" + vo); UserInfo4DPL exit = pIndex.put(vo); System.out.println("after put get the key exit object:\n" + exit); } UserInfo4DPL data = list.get(0); System.out .println("Ojbect 'description' change to http://weibo.com/ctosun"); data.setDescription("http://weibo.com/ctosun"); System.out.println("put object:\n" + data); UserInfo4DPL retData2 = pIndex.put(data); System.out.println("after put get the key exit object:\n" + retData2); System.out.println("注意:put返回结果是当前key的前一个值"); } catch (Exception e) { e.printStackTrace(); } finally { if (null != store) { store.close(); } if (null != mydbEnv) { // 在关闭环境前清理下日志 mydbEnv.cleanLog(); mydbEnv.close(); mydbEnv = null; } } } /** * 演示数据读取 * * @param envHomePath */ public void testDPLPkeyRead(String envHomePath, String storeName) { Environment mydbEnv = null; EntityStore store = null; try { EnvironmentConfig envCfg = new EnvironmentConfig(); envCfg.setAllowCreate(true); envCfg.setTransactional(true); mydbEnv = new Environment(new File(envHomePath), envCfg); StoreConfig storeConfig = new StoreConfig(); storeConfig.setAllowCreate(true); storeConfig.setTransactional(true); store = new EntityStore(mydbEnv, storeName, storeConfig); System.out.println(" ---- > Read data by PrimaryIndex ..."); PrimaryIndex<String, UserInfo4DPL> pIndex = store.getPrimaryIndex( String.class, UserInfo4DPL.class); String myKey = "ctosun"; System.out.println("Get data by the key:" + myKey); UserInfo4DPL getData = pIndex.get(myKey); System.out.println("the key value:\n" + getData); System.out.println(" ---- > Read All data list: "); EntityCursor<UserInfo4DPL> cursor = pIndex.entities(); try { Iterator<UserInfo4DPL> i = cursor.iterator(); while (i.hasNext()) { System.out.println("cursor data:" + i.next()); } } finally { cursor.close(); } } catch (Exception e) { e.printStackTrace(); } finally { if (null != store) { store.close(); } if (null != mydbEnv) { // 在关闭环境前清理下日志 mydbEnv.cleanLog(); mydbEnv.close(); mydbEnv = null; } } } /** * 演示数据删除 * * @param envHomePath */ public void testDPLPkeyDelete(String envHomePath, String storeName) { Environment mydbEnv = null; EntityStore store = null; try { EnvironmentConfig envCfg = new EnvironmentConfig(); envCfg.setAllowCreate(true); envCfg.setTransactional(true); mydbEnv = new Environment(new File(envHomePath), envCfg); StoreConfig storeConfig = new StoreConfig(); storeConfig.setAllowCreate(true); // 做删除操作时事务设置为false storeConfig.setTransactional(false); store = new EntityStore(mydbEnv, storeName, storeConfig); PrimaryIndex<String, UserInfo4DPL> pIndex = store.getPrimaryIndex( String.class, UserInfo4DPL.class); System.out.println(" ---- > Before delete display all list: "); EntityCursor<UserInfo4DPL> cursor = pIndex.entities(); try { Iterator<UserInfo4DPL> i = cursor.iterator(); while (i.hasNext()) { System.out.println("cursor data:" + i.next()); } } finally { cursor.close(); } System.out.println(" ---- > Delete data by Primarykey "); String pkey = "micmiu"; boolean flag = pIndex.delete(pkey); System.out.println("delete object :" + pkey + " result:" + flag); System.out.println(" ---- > Delete data by EntityCursor"); cursor = pIndex.entities(); try { Iterator<UserInfo4DPL> i = cursor.iterator(); while (i.hasNext()) { UserInfo4DPL vo = i.next(); if ("007".equals(vo.getUserId())) { System.out.println("delete object :" + vo); i.remove(); } } } finally { cursor.close(); } System.out.println(" ---- > After delete display all list: "); cursor = pIndex.entities(); try { for (UserInfo4DPL vo : cursor) { System.out.println("cursor data:" + vo); } } finally { cursor.close(); } } catch (Exception e) { e.printStackTrace(); } finally { if (null != store) { store.close(); } if (null != mydbEnv) { // 在关闭环境前清理下日志 mydbEnv.cleanLog(); mydbEnv.close(); mydbEnv = null; } } } private List<UserInfo4DPL> initObject() { List<UserInfo4DPL> list = new ArrayList<UserInfo4DPL>(); list.add(new UserInfo4DPL("ctosun", "Michael", "welcome to www.micmiu.com")); list.add(new UserInfo4DPL("micmiu", "Michael", "welcome to www.micmiu.com")); list.add(new UserInfo4DPL("sjsky", "Michael", "welcome to www.micmiu.com")); list.add(new UserInfo4DPL("007", "Michael", "welcome to www.micmiu.com")); return list; } /** * @param args */ public static void main(String[] args) { System.out.println(" ==== > Demo Test Start < ===="); DPLPrimaryIndexsDemo demo = new DPLPrimaryIndexsDemo(); String envHomePath = "D:/test/berkeleydata"; String storeName = "micmiu-DPL-demo"; System.out.println(" ==== > 测试数据 存储..."); demo.testDPLPkeyPut(envHomePath, storeName); System.out.println(" ==== > 测试数据 读取..."); demo.testDPLPkeyRead(envHomePath, storeName); System.out.println(" ==== > 测试数据 删除..."); demo.testDPLPkeyDelete(envHomePath, storeName); System.out.println(" ==== > Demo Test End < ===="); } } |
运行结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
==== > Demo Test Start < ==== ==== > 测试数据 存储... ---- > put data by PrimaryIndex ... put object: UserInfo4DPL [userId=ctosun, userName=Michael, description=welcome to www.micmiu.com] after put get the key exit object: null put object: UserInfo4DPL [userId=micmiu, userName=Michael, description=welcome to www.micmiu.com] after put get the key exit object: null put object: UserInfo4DPL [userId=sjsky, userName=Michael, description=welcome to www.micmiu.com] after put get the key exit object: null put object: UserInfo4DPL [userId=007, userName=Michael, description=welcome to www.micmiu.com] after put get the key exit object: null Ojbect 'description' change to http://weibo.com/ctosun put object: UserInfo4DPL [userId=ctosun, userName=Michael, description=http://weibo.com/ctosun] after put get the key exit object: UserInfo4DPL [userId=ctosun, userName=Michael, description=welcome to www.micmiu.com] 注意:put返回结果是当前key的前一个值 ==== > 测试数据 读取... ---- > Read data by PrimaryIndex ... Get data by the key:ctosun the key value: UserInfo4DPL [userId=ctosun, userName=Michael, description=http://weibo.com/ctosun] ---- > Read All data list: cursor data:UserInfo4DPL [userId=007, userName=Michael, description=welcome to www.micmiu.com] cursor data:UserInfo4DPL [userId=ctosun, userName=Michael, description=http://weibo.com/ctosun] cursor data:UserInfo4DPL [userId=micmiu, userName=Michael, description=welcome to www.micmiu.com] cursor data:UserInfo4DPL [userId=sjsky, userName=Michael, description=welcome to www.micmiu.com] ==== > 测试数据 删除... ---- > Before delete display all list: cursor data:UserInfo4DPL [userId=007, userName=Michael, description=welcome to www.micmiu.com] cursor data:UserInfo4DPL [userId=ctosun, userName=Michael, description=http://weibo.com/ctosun] cursor data:UserInfo4DPL [userId=micmiu, userName=Michael, description=welcome to www.micmiu.com] cursor data:UserInfo4DPL [userId=sjsky, userName=Michael, description=welcome to www.micmiu.com] ---- > Delete data by Primarykey delete object :micmiu result:true ---- > Delete data by EntityCursor delete object :UserInfo4DPL [userId=007, userName=Michael, description=welcome to www.micmiu.com] ---- > After delete display all list: cursor data:UserInfo4DPL [userId=ctosun, userName=Michael, description=http://weibo.com/ctosun] cursor data:UserInfo4DPL [userId=sjsky, userName=Michael, description=welcome to www.micmiu.com] ==== > Demo Test End < ==== |
[二]、第二索引(Secondary Indexes)的应用
- ONE_TO_ONE
- MANY_TO_ONE
- ONE_TO_MANY
- MANY_TO_MANY
下面以 MANY_TO_ONE 为例做个基本演示
持久化存储的对象:BlogItem.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
package com.micmiu.berkeley.demo.vo; import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.PrimaryKey; import static com.sleepycat.persist.model.Relationship.*; import com.sleepycat.persist.model.SecondaryKey; /** * * @author <a href="http://www.micmiu.com">Michael Sun</a> */ @Entity public class BlogItem { @PrimaryKey private String no; @SecondaryKey(relate = MANY_TO_ONE) private String category; private String itemName; private String author; public String getNo() { return no; } public String getCategory() { return category; } public String getItemName() { return itemName; } public String getAuthor() { return author; } public void setNo(String no) { this.no = no; } public void setCategory(String category) { this.category = category; } public void setItemName(String itemName) { this.itemName = itemName; } public void setAuthor(String author) { this.author = author; } @Override public String toString() { return "BlogItem [no=" + no + ", category=" + category + ", itemName=" + itemName + ", author=" + author + "]"; } } |
读取操作的演示代码:DPLSecondaryIndexesDemo.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
package com.micmiu.berkeley.demo; import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import com.micmiu.berkeley.demo.vo.BlogItem; import com.sleepycat.je.Environment; import com.sleepycat.je.EnvironmentConfig; import com.sleepycat.persist.EntityCursor; import com.sleepycat.persist.EntityStore; import com.sleepycat.persist.PrimaryIndex; import com.sleepycat.persist.SecondaryIndex; import com.sleepycat.persist.StoreConfig; /** * * @author <a href="http://www.micmiu.com">Michael Sun</a> */ public class DPLSecondaryIndexesDemo { /** * 演示数据存储 * * @param envHomePath */ public void testDPLSecondaryIndexesPut(String envHomePath, String storeName) { Environment mydbEnv = null; EntityStore store = null; try { EnvironmentConfig envCfg = new EnvironmentConfig(); envCfg.setAllowCreate(true); envCfg.setTransactional(true); mydbEnv = new Environment(new File(envHomePath), envCfg); StoreConfig storeConfig = new StoreConfig(); storeConfig.setAllowCreate(true); storeConfig.setTransactional(true); store = new EntityStore(mydbEnv, storeName, storeConfig); System.out .println(" ---- > put objects with Secondary Indexes ..."); PrimaryIndex<String, BlogItem> pIndex = store.getPrimaryIndex( String.class, BlogItem.class); List<BlogItem> itemList = this.loadData(); for (BlogItem item : itemList) { System.out.println("put object:" + item); pIndex.put(item); } System.out.println(" ---- > put all objects finished"); } catch (Exception e) { e.printStackTrace(); } finally { if (null != store) { store.close(); } if (null != mydbEnv) { // 在关闭环境前清理下日志 mydbEnv.cleanLog(); mydbEnv.close(); mydbEnv = null; } } } /** * 演示数据读取 * * @param envHomePath */ public void testDPLSecondaryIndexesRead(String envHomePath, String storeName) { Environment mydbEnv = null; EntityStore store = null; try { EnvironmentConfig envCfg = new EnvironmentConfig(); envCfg.setAllowCreate(true); envCfg.setTransactional(true); mydbEnv = new Environment(new File(envHomePath), envCfg); StoreConfig storeConfig = new StoreConfig(); storeConfig.setAllowCreate(true); storeConfig.setTransactional(true); store = new EntityStore(mydbEnv, storeName, storeConfig); System.out.println(" ---- > get objects by Indexes ..."); PrimaryIndex<String, BlogItem> pIndex = store.getPrimaryIndex( String.class, BlogItem.class); SecondaryIndex<String, String, BlogItem> sIndex = store .getSecondaryIndex(pIndex, String.class, "category"); String pkey = "2001"; System.out.println("get objects by PrimaryIndex:" + pkey); BlogItem item4PI = pIndex.get(pkey); System.out.println(pkey + " data:\n" + item4PI); String skey = "J2EE"; System.out.println("get objects by SecondaryIndex:" + skey); BlogItem item4SI = sIndex.get(skey); System.out.println(skey + " data:\n" + item4SI); System.out.println(" ---- > Retrieving Multiple Objects ..."); System.out.println(" ---- > Retrieving All Objects by Cursor"); // 根据游标获取所有数据 EntityCursor<BlogItem> cursor4PI = pIndex.entities(); try { Iterator<BlogItem> i = cursor4PI.iterator(); while (i.hasNext()) { System.out.println("cursor data:" + i.next()); } } finally { cursor4PI.close(); } System.out.println(" ---- > Retrieving Duplicate Keys "); // 根据第二索引查找数据 EntityCursor<BlogItem> cursor4SI = sIndex.subIndex(skey).entities(); try { for (BlogItem item : cursor4SI) { System.out.println("cursor data:" + item); } } finally { cursor4SI.close(); } } catch (Exception e) { e.printStackTrace(); } finally { if (null != store) { store.close(); } if (null != mydbEnv) { // 在关闭环境前清理下日志 mydbEnv.cleanLog(); mydbEnv.close(); mydbEnv = null; } } } /** * 演示数据删除 * * @param envHomePath */ public void testDPLSecondaryIndexesDelete(String envHomePath, String storeName) { Environment mydbEnv = null; EntityStore store = null; try { EnvironmentConfig envCfg = new EnvironmentConfig(); envCfg.setAllowCreate(true); envCfg.setTransactional(true); mydbEnv = new Environment(new File(envHomePath), envCfg); StoreConfig storeConfig = new StoreConfig(); storeConfig.setAllowCreate(true); // 运用游标删除数据时事务要设置为false,否则报错 storeConfig.setTransactional(false); store = new EntityStore(mydbEnv, storeName, storeConfig); PrimaryIndex<String, BlogItem> pIndex = store.getPrimaryIndex( String.class, BlogItem.class); SecondaryIndex<String, String, BlogItem> sIndex = store .getSecondaryIndex(pIndex, String.class, "category"); System.out.println(" ---- > before delete query list ..."); // 根据游标获取所有数据 EntityCursor<BlogItem> cursor4PI = pIndex.entities(); try { for (BlogItem item : cursor4PI) { System.out.println("exit data:" + item); } } finally { cursor4PI.close(); } System.out.println(" ---- > Delete Objects by PrimaryIndex"); cursor4PI = pIndex.entities(); try { Iterator<BlogItem> i = cursor4PI.iterator(); while (i.hasNext()) { BlogItem vo = i.next(); if ("Struts".equals(vo.getItemName())) { System.out.println("delete :" + vo); i.remove(); } } } finally { cursor4PI.close(); } System.out.println(" ---- > Delete Objects by SecondaryIndex "); String skey = "Language"; EntityCursor<BlogItem> cursor4SI = sIndex.subIndex(skey).entities(); try { Iterator<BlogItem> i = cursor4SI.iterator(); while (i.hasNext()) { BlogItem vo = i.next(); if ("Groovy".equals(vo.getItemName())) { System.out.println("delete :" + vo); i.remove(); } } } finally { cursor4SI.close(); } System.out.println(" ---- > aftre delete query list ..."); // 根据游标获取所有数据 cursor4PI = pIndex.entities(); try { for (BlogItem item : cursor4PI) { System.out.println("exit data:" + item); } } finally { cursor4PI.close(); } } catch (Exception e) { e.printStackTrace(); } finally { if (null != store) { store.close(); } if (null != mydbEnv) { // 在关闭环境前清理下日志 mydbEnv.cleanLog(); mydbEnv.close(); mydbEnv = null; } } } /** * 初始化一批数据 * * @return */ private List<BlogItem> loadData() { List<BlogItem> list = new ArrayList<BlogItem>(); BlogItem item = new BlogItem(); item.setNo("1001"); item.setCategory("J2EE"); item.setItemName("Spring"); item.setAuthor("Michael"); list.add(item); item = new BlogItem(); item.setNo("1002"); item.setCategory("J2EE"); item.setItemName("Hibernate"); item.setAuthor("Michael"); list.add(item); item = new BlogItem(); item.setNo("1003"); item.setCategory("J2EE"); item.setItemName("Struts"); item.setAuthor("Michael"); list.add(item); item = new BlogItem(); item.setNo("2001"); item.setCategory("Language"); item.setItemName("Java"); item.setAuthor("Michael"); list.add(item); item = new BlogItem(); item.setNo("2002"); item.setCategory("Language"); item.setItemName("Groovy"); item.setAuthor("Michael"); list.add(item); return list; } /** * @param args */ public static void main(String[] args) { System.out.println(" ==== > Demo Test Start < ===="); DPLSecondaryIndexesDemo demo = new DPLSecondaryIndexesDemo(); String envHomePath = "D:/test/berkeleydata"; String storeName = "micmiu-DPL-demo"; System.out.println(" ==== > 测试数据 存储..."); demo.testDPLSecondaryIndexesPut(envHomePath, storeName); System.out.println(" ==== > 测试数据 读取..."); demo.testDPLSecondaryIndexesRead(envHomePath, storeName); System.out.println(" ==== > 测试数据 删除..."); demo.testDPLSecondaryIndexesDelete(envHomePath, storeName); System.out.println(" ==== > Demo Test End < ===="); } } |
运行结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
==== > Demo Test Start < ==== ==== > 测试数据 存储... ---- > put objects with Secondary Indexes ... put object:BlogItem [no=1001, category=J2EE, itemName=Spring, author=Michael] put object:BlogItem [no=1002, category=J2EE, itemName=Hibernate, author=Michael] put object:BlogItem [no=1003, category=J2EE, itemName=Struts, author=Michael] put object:BlogItem [no=2001, category=Language, itemName=Java, author=Michael] put object:BlogItem [no=2002, category=Language, itemName=Groovy, author=Michael] ---- > put all objects finished ==== > 测试数据 读取... ---- > get objects by Indexes ... get objects by PrimaryIndex:2001 2001 data: BlogItem [no=2001, category=Language, itemName=Java, author=Michael] get objects by SecondaryIndex:J2EE J2EE data: BlogItem [no=1001, category=J2EE, itemName=Spring, author=Michael] ---- > Retrieving Multiple Objects ... ---- > Retrieving All Objects by Cursor cursor data:BlogItem [no=1001, category=J2EE, itemName=Spring, author=Michael] cursor data:BlogItem [no=1002, category=J2EE, itemName=Hibernate, author=Michael] cursor data:BlogItem [no=1003, category=J2EE, itemName=Struts, author=Michael] cursor data:BlogItem [no=2001, category=Language, itemName=Java, author=Michael] cursor data:BlogItem [no=2002, category=Language, itemName=Groovy, author=Michael] ---- > Retrieving Duplicate Keys cursor data:BlogItem [no=1001, category=J2EE, itemName=Spring, author=Michael] cursor data:BlogItem [no=1002, category=J2EE, itemName=Hibernate, author=Michael] cursor data:BlogItem [no=1003, category=J2EE, itemName=Struts, author=Michael] ==== > 测试数据 删除... ---- > before delete query list ... exit data:BlogItem [no=1001, category=J2EE, itemName=Spring, author=Michael] exit data:BlogItem [no=1002, category=J2EE, itemName=Hibernate, author=Michael] exit data:BlogItem [no=1003, category=J2EE, itemName=Struts, author=Michael] exit data:BlogItem [no=2001, category=Language, itemName=Java, author=Michael] exit data:BlogItem [no=2002, category=Language, itemName=Groovy, author=Michael] ---- > Delete Objects by PrimaryIndex delete :BlogItem [no=1003, category=J2EE, itemName=Struts, author=Michael] ---- > Delete Objects by SecondaryIndex delete :BlogItem [no=2002, category=Language, itemName=Groovy, author=Michael] ---- > aftre delete query list ... exit data:BlogItem [no=1001, category=J2EE, itemName=Spring, author=Michael] exit data:BlogItem [no=1002, category=J2EE, itemName=Hibernate, author=Michael] exit data:BlogItem [no=2001, category=Language, itemName=Java, author=Michael] ==== > Demo Test End < ==== |
本文介绍到此结束@Michael Sun.
原创文章,转载请注明: 转载自micmiu – 软件开发+生活点滴[ http://www.micmiu.com/ ]
0 条评论。