Summary
adds a new Alias for a class, namespace or package.
- Assembly
- Db4objects
.Db4o-2010 .dll - Namespace
- Db4objects
.Db4o .Config - Containing Type
- ICommonConfiguration
Syntax
void AddAlias(IAlias alias)
Remarks
adds a new Alias for a class, namespace or package.
Aliases can be used to persist classes in the running application to different persistent classes in a database file or on a db4o server.
Two simple Alias implementations are supplied along with db4o:
-
-
It is possible to create own complex
Examples of concrete usecases:
Aliases that translate the persistent name of a class to a name that already exists as a persistent name in the database (or on the server) are not permitted and will throw an exception when the database file is opened.
Aliases should be configured before opening a database file or connecting to a server.
In client/server environment it is good practice to configure the client and the server in exactly the same way.
Aliases can be used to persist classes in the running application to different persistent classes in a database file or on a db4o server.
Two simple Alias implementations are supplied along with db4o:
-
Db4objects.Db4o.Config.TypeAlias
provides an #equals() resolver to match
names directly.-
Db4objects.Db4o.Config.WildcardAlias
allows simple pattern matching
with one single '*' wildcard character.It is possible to create own complex
Db4objects.Db4o.Config.IAlias
constructs by creating own resolvers
that implement the
Db4objects.Db4o.Config.IAlias
interface.
Examples of concrete usecases:
// Creating an Alias for a single class
EmbeddedConfiguration config = Db4oEmbedded.newConfiguration();
config.common().addAlias(
new TypeAlias("com.f1.Pilot", "com.f1.Driver"));
// Mapping a Java package onto another
config.common().addAlias(
new WildcardAlias(
"com.f1.*",
"com.f1.client*"));
Aliases that translate the persistent name of a class to a name that already exists as a persistent name in the database (or on the server) are not permitted and will throw an exception when the database file is opened.
Aliases should be configured before opening a database file or connecting to a server.
In client/server environment it is good practice to configure the client and the server in exactly the same way.
Parameters
Name | Type | Description |
---|---|---|
alias | IAlias |
Return Value
Type | Description |
---|---|
void |