persistence@glassfish.java.net

Re: schema and catalog attributes of _at_Table

From: Varun Rupela <Varun.Rupela_at_Sun.COM>
Date: Tue, 03 Oct 2006 16:19:46 +0530

Marina Vatkina wrote:
> Varun Rupela wrote:
>> Marina Vatkina wrote:
>>
>>> Hi Varun,
>>>
>>> Oracle does support catalogs, and schema name is your userid:
>>> http://download-west.oracle.com/docs/cd/B19188_01/doc/B15917/squse.htm#sthref46
>>>
>>>
>>> I would think it should be a user responsibility to provide only
>>> relevant info
>>> (why would they specify catalog if it's not used in their
>>> database?). But you
>>> can file an RFE for Derby to skip catalog name from the identifier.
>>
>>
>> I understand. thanks.
>>
>> Remaining Issue:
>> The ddl-generator generates table name references that look like
>> "schemaName.catalogName.tableName" (tried derby and oracle). Based on
>> the documentation links discussed, is it valid to file a bug so the
>> table references are corrected to look like -
>> "catalogName.schemaName.tableName" ?
>
> Right. Can you check if it's only a java2db problem, or at the runtime
> the
> tables are not qualified properly?

I filed issue 1234 for this.
I do not currently have a catalog created and at run time, the create
statement with a table name like "schemaName.catalogName.tableName"
throws an error with oracle (missing or invalid option).

Question:
If the catalog attribute of @Table is used the table name generated is
"catalogName.tableName". Is such a reference to the table valid? If not,
is this a user error (meaning the user must ensure that the schema
attribute is used whenever the catalog attribute is used) OR is this an
RFE for java2db to throw an error when catalog is used without schema?
>
> thanks,
> -marina
>
>>
>> thanks.
>>
>> varun
>>
>>>
>>> thanks,
>>> -marina
>>>
>>> Varun Rupela wrote:
>>>
>>>> Hi Marina:
>>>>
>>>> Yes. I think you are correct. A catalog is a collection of schemas.
>>>> I Only found the following links to suggest that:
>>>> http://www.tar.hu/sqlbible/sqlbible0098.html
>>>> http://knowledgebase.datadirect.com/kbase.nsf/SupportLink%20Online/2548600HD?OpenDocument
>>>>
>>>> http://mailgate.supereva.com/comp/comp.databases.rdb/msg01094.html
>>>>
>>>> Also, it seems that not all databases support the concept of a
>>>> catalog. (As far as I can tell, Derby and Oracle don't support
>>>> catalog)
>>>>
>>>> So -
>>>> 1. It looks like the wrong ddl is being generated when both the
>>>> schema and catalog attributes are used in annotations or via xml
>>>> mapping. Should I file a bug for this?
>>>> 2. Should the generated ddl ignore the catalog attribute for
>>>> databases that do not support catalog?
>>>>
>>>> thanks.
>>>>
>>>> varun.
>>>>
>>>>
>>>> Marina Vatkina wrote:
>>>>
>>>>> Varun,
>>>>>
>>>>> I'm confused... shouldn't it be catalogName.schemaName.tableName?
>>>>>
>>>>> thanks,
>>>>> -marina
>>>>>
>>>>> Varun Rupela wrote:
>>>>>
>>>>>> Hi:
>>>>>>
>>>>>> Using the schema and catalog attribute of @Table (or <table> in
>>>>>> orm.xml) and using ddl-generation causes the generated ddl to
>>>>>> have dotted table name references of the following type:
>>>>>> schemaName.catalogName.tableName.
>>>>>>
>>>>>> Now, Derby doesn't like a statement "create table
>>>>>> schemaName.catalogName.tableName" and throws an exception that
>>>>>> the Provider logs with the following Warning:
>>>>>> [TopLink Warning]: 2006.09.25
>>>>>> 02:21:46.567--ServerSession(22591049)--Exception [TOPLINK-4002]
>>>>>> (Oracle TopLink Essentials - 2006.8 (Build 060908)):
>>>>>> oracle.toplink.essentials.exceptions.DatabaseException
>>>>>> Internal Exception: org.apache.derby.client.am.SqlException:
>>>>>> Syntax error: Encountered "." at line 1, column 36.Error Code: -1
>>>>>> Call:CREATE TABLE
>>>>>> schema_XML.catalog_XML.OverridingTableAnnotation_FROM_XML (ID
>>>>>> BIGINT NOT NULL, DEPTNAME VARCHAR(255) NOT NULL, DEPTCOLORCODE
>>>>>> VARCHAR(255) NOT NULL, PRIMARY KEY (ID))
>>>>>> Query:DataModifyQuery()
>>>>>>
>>>>>> - After doing some search and speaking to some folks working on
>>>>>> Derby, it seems that catalogName doesn't have a meaning when used
>>>>>> as above. Is the ddl-generator expected to ignore the entry for
>>>>>> catalog when generating ddl for Derby? Is this a bug?
>>>>>> - Not using catalog but using schema generates a statement like
>>>>>> "create table schemaName.tableName" which derby does execute
>>>>>> correctly.
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> varun.