Database query is a language used to communicate with the database. For a long time databases stood the central and commanding place in software products: the applications were literally written to support the needs of a main central database. However, in the modern high-speed world of distribute computing the transfer and modification of the information plays increasingly important role and the databases more and more often take a place of a temporary storage or a point of exchange.
This evolutionary change results in some practical modifications: more attention is paid to the business logic and tools that are used for its development, language structures are automatically produced and checked by development environments and string-based logic is getting outdated and not enough efficient. Database query language is expected to follow the features of an object-oriented language: type-safe, easy to refactor and test. String-based languages like SQL, OQL, JDOQL do not meet these requirements. To fill this gap and provide developers with sufficient database query tools a new concept was developed by W.Cook and C. Rosenberger which was given a name Native Queries.
In the following paragraphs, we will review the concepts of Native Queries (NQ). We will use Pilot class for all examples suggested further:
01/* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com */ 02
namespace Db4objects.Db4odoc.NQConcepts 03
{ 04
public class Pilot 05
{ 06
string _name; 07
int _points; 08
09
public Pilot(string name, int points) 10
{ 11
_name = name; 12
_points = points; 13
} 14
15
public int Points 16
{ 17
get 18
{ 19
return _points; 20
} 21
} 22
23
public string Name 24
{ 25
get 26
{ 27
return _name; 28
} 29
} 30
} 31
}