db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Hillegas (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-651) Re-enable the storing of java objects in the database
Date Tue, 24 Nov 2009 15:55:39 GMT

     [ https://issues.apache.org/jira/browse/DERBY-651?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Rick Hillegas updated DERBY-651:
--------------------------------

    Attachment: derby-651-02-af-udtColumnsRetvalsParams.diff

Attaching derby-651-02-af-udtColumnsRetvalsParams.diff. This patch makes it possible to create
UDT columns and store UDTs in them. This patch also makes it possible to pass UDTs as parameters
into functions and procedures and to return UDTs from functions. The following is possible
with this patch:

	create type Price external name 'org.apache.derbyTesting.functionTests.tests.lang.Price'
language java;

	create table orders( orderID int generated always as identity, customerID int, totalPrice
price );

	create function makePrice( currencyCode char( 3 ), amount decimal( 31, 5 ), timeInstant Timestamp
)
        returns Price language java parameter style java no sql
        external name 'org.apache.derbyTesting.functionTests.tests.lang.Price.makePrice';
	create function getCurrencyCode( price Price ) returns char( 3 ) language java parameter
style java no sql
        external name 'org.apache.derbyTesting.functionTests.tests.lang.Price.getCurrencyCode';
	create function getAmount( price Price ) returns decimal( 31, 5 ) language java parameter
style java no sql
        external name 'org.apache.derbyTesting.functionTests.tests.lang.Price.getAmount';
	create function getTimeInstant( price Price ) returns timestamp language java parameter style
java no sql
        external name 'org.apache.derbyTesting.functionTests.tests.lang.Price.getTimeInstant';

	insert into orders( customerID, totalPrice ) values
        ( 12345, makePrice( 'USD', cast( 9.99 as decimal( 31, 5 ) ), timestamp('2009-10-16
14:24:43') ) );

	select getCurrencyCode( totalPrice ), getAmount( totalPrice ), getTimeInstant( totalPrice
) from orders;

	select totalPrice from orders;


At least for small UDTs, it turns out that Derby still has the logic needed to store the UDT
values in columns. It appears (although I have not tested this yet), that the Store can probably
persist UDT values for UDTs which implement SQLData in addition to UDTs which implement Serializable.
What was needed was the ability to identify UDTs by schema qualified names. Touches the following
files:

M      java/engine/org/apache/derby/iapi/types/TypeId.java
M      java/engine/org/apache/derby/iapi/types/UserType.java
M      java/engine/org/apache/derby/catalog/TypeDescriptor.java
M      java/engine/org/apache/derby/catalog/types/DecimalTypeIdImpl.java
M      java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java
M      java/engine/org/apache/derby/catalog/types/BaseTypeIdImpl.java
M      java/engine/org/apache/derby/catalog/types/UserDefinedTypeIdImpl.java

This adds a persistable schema qualified name to the existing UserDefinedType object.


M      java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
M      java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
M      java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java
M      java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java

Changes to allow schema qualified UDT names in CREATE TABLE/FUNCTION/PROCEDURE statements.


M      java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java

Adds logic to bind a UDT declaration. This means looking up the UDT in the DataDictionary
given its schema qualified name and then poking the corresponding Java class name into the
UDT type descriptor.


M      java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java

Small changes to support the use of UDT values at execution time.



A      java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java

Some basic tests to verify that you can create columns, parameters, and return values of UDT
type.


M      java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorCodeTest.java
M      java/testing/org/apache/derbyTesting/functionTests/master/db2Compatibility.out

Changes some tests to account for the fact that the parser now raises a different error when
it encounters illegal type declarations.


The regression tests pass for me.


> Re-enable the storing of java objects in the database
> -----------------------------------------------------
>
>                 Key: DERBY-651
>                 URL: https://issues.apache.org/jira/browse/DERBY-651
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>            Reporter: Rick Hillegas
>         Attachments: derby-651-01-aa-basicCreateDropType.diff, derby-651-02-af-udtColumnsRetvalsParams.diff,
UserDefinedTypes.html, UserDefinedTypes.html, UserDefinedTypes.html, UserDefinedTypes.html
>
>
> Islay Symonette, in an email thread called "Storing Java Objects in a table" on October
26, 2005 requests the ability to store java objects in the database.
> Old releases of Cloudscape allow users to declare a column's type to be a Serializable
class. This feature was removed from Derby because the syntax was non-standard. However, most
of the machinery to support objects serialized to columns is still in Derby and is even used
in system tables. We need to agree on some standard syntax here and re-expose this useful
feature. Some subset of the ANSI adt syntax, cumbersome as it is, would do.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message