One of the most valuable aliases usecases is working with persistent Java classes from a .NET application and vice versa. You can use both TypeAlias and WildcardAlias depending on how many classes you need to access.
For example, Pilot objects are saved to a database from a Java application:
01private static void saveObjects(){ 02
new File(DB4O_FILE_NAME ).delete(); 03
ObjectContainer container = Db4o.openFile(DB4O_FILE_NAME); 04
try { 05
Pilot pilot = new Pilot("David Barrichello",99); 06
container.set(pilot); 07
pilot = new Pilot("Michael Schumacher",100); 08
container.set(pilot); 09
} finally { 10
container.close(); 11
} 12
}
In order to read the saved objects successfully from a .NET application we will need to define an alias for persistent classes and an alias for the Db4oDatabase class. We will use a wildcard alias for all the persistent classes:
Now the objects are accessible from the .NET application:One thing to remember: field names in class definitions in Java and .NET should be exactly the same.