![]()
![]() ![]() ![]() ![]() ![]() ![]() ![]() Documentation Top ![]() Global Index ![]() Reference Manual ![]() ![]() ![]() Developer's Guide ![]() ![]() Tuning Cloudscape ![]() ![]() |
Field AccessYou can access the field of an object or class. Object fields can be static or non-static, and are accessed from instances of Java classes. Class fields are static, and are accessed from Java classes. Only public fields are accessible through SQL-J. Private, protected, and package fields are not accessible through SQL-J. The fields that can be accessed are those that are declared as public in the Java class of the expressions declared data type. The declared data type of an expression is its type as determined by the declared types of columns, the declared return types of methods, and the expected result types of the various SQL-J expressions based on the operand(s) involved in the expressions. Syntax
NEW: Field access works with the new class alias construct. See CREATE CLASS ALIAS statement. ExampleInteraction with Java Data TypesYou can perform field accesses on any SQL-J expression that evaluates Java object or class. Every SQL-J expression has an SQL-J type; every SQL-J type has a corresponding Java class. This means that you can perform field accesses on the corresponding class of SQL-J expressions, returning the result of the field access on that class. The field can be in the corresponding class or in any class within the superclass hierarchy. Field Access and Type ConversionsThe values returned by field accesses are converted to SQL-J types in most cases. For more information about the Java to SQL-J type conversion of return values, see Java to SQL-J Type Correspondence. Field Access and Null ValuesNEW: In prior releases, if an expression referenced a Java field that was null, the JVM threw a NullPointerException. Beginning in Version 3.0, a reference to a null Java field returns an SQL-J NULL. Primitive types in java (boolean, char, byte, short, int, long, float, and double) cannot be null. So, when a null value is used to reference a non-static field, the field reference evaluates to null only if the value is being returned to the SQL domain. If the value is being returned to another Java construct, a NullPointerException is raised. For example, in the following SQL-J statement, where the city column is null, a null is returned: However, the situation changes when the return value of that method call is passed to another Java construct: In this situation, if the City column contains any nulls, a NullPointerException is raised because the null value is passed to the Java constructor, which does not accept nulls. Static Field Access and Null ValuesIt is possible to access a static field, however, off of a null receiver. In the following example, the value of the static field is returned, not an SQL NULL: Class Alias and Column Name AmbiguitySee the discussion under Method Invocation. | ||
![]() ![]() ![]() ![]() ![]() ![]() | ![]() ![]() Cloudscape Version 3.0 ![]() For technical support, go to: www.cloudscape.com and click Support. Copyright © 1998 and 1999 Cloudscape, Inc. All rights reserved. |