Multidimensional Arrays

Currently you can't use multidimensional array fields in a server without persistent classes setup.  

RecordBook.java
01/* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com */ 02 03package com.db4odoc.noclasses.client; 04 05 06public class RecordBook { 07 private String[][] notes; 08 private int recordCounter; 09 10 11 public RecordBook(){ 12 notes = new String[20][3]; 13 recordCounter = 0; 14 } 15 16 public void addRecord(String period, String pilotName, String note){ 17 String[] tempArray = {period, pilotName, note}; 18 notes[recordCounter] = tempArray; 19 recordCounter ++; 20 } 21 22 public String toString(){ 23 String temp; 24 temp = "Record book: \n"; 25 for (int i=0; i<recordCounter;i++ ){ 26 temp = temp + notes[i][0] + "/" + notes[i][1] + "/" + notes[i][2] + "\n"; 27 } 28 return temp; 29 } 30}
Client.java: saveMultiArray
01private static void saveMultiArray() throws IOException { 02 System.out.println("Testing saving an object with multidimentional array field"); 03 ObjectContainer oc = Db4o.openClient("localhost", 0xdb40, "db4o","db4o"); 04 try { 05 RecordBook recordBook = new RecordBook(); 06 recordBook.addRecord("September 2006", "Michael Schumacher", "last race"); 07 recordBook.addRecord("September 2006", "Kimi Raikkonen", "no notes"); 08 oc.set(recordBook); 09 } finally { 10 oc.close(); 11 } 12 }
Client.java: getMultiArray
01private static void getMultiArray() throws IOException { 02 System.out.println("Testing retrieving an object with multidimentional array field"); 03 ObjectContainer oc = Db4o.openClient("localhost", 0xdb40, "db4o","db4o"); 04 try { 05 ObjectSet result = oc.get(new RecordBook()); 06 listResult(result); 07 } finally { 08 oc.close(); 09 } 10 }