Home » Modeling » EMF » [CDO] Oracle Adapter Wanted(CDO)
| |
Re: [CDO] Oracle Adapter Wanted [message #662420 is a reply to message #662369] |
Wed, 30 March 2011 15:32 |
|
Hey Guys,
The implementation of the adapter (not the driver) has been accidentally deleted by the webmasters: https://bugs.eclipse.org/bugs/show_bug.cgi?id=270428 . You may want to contact Hasan and see if he can find it again on one of his drives. I'd be more than happy to review that code and push it through the IP clearance at Eclipse.
My personal guess is that a new implementation is not too costly, either. I've only been reluctant to do it, because of the flood of different JDBC drivers on my box that are needed to entertain all these DBs. And I have no experience with Oracle myself. If you look at some of the other DBAdapters you'll find out that they do not contain a lot of code.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Am 30.03.2011 05:22, schrieb Heiko:
> Hi,
> at the moment I know only one way, which goes over the CDO Hibernate Store.
> Examples for this (not direct for an Oracle DB) should you find there: http://dev.eclipse.org/viewcvs/viewvc.cgi/trunk/plugins/?roo t=Modeling_CDO
>
> If you following the CDO Source Installation Tutorial ( http://wiki.eclipse.org/CDO_Source_Installation ), you would have all needed files in your workspace.
>
> At the way over the CDO DB Store, there are only an old bug, but no implementation ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=270428 )
>
> Hope it helps
>
> Heiko
>
> Am 30.03.2011 11:40, schrieb David Skogan:
>> Hi,
>>
>> Could someone please provide information about how to connect to a
>> oracle database over CDO.
>> Source code or examples would be nice.
>>
>> Regards
>> David
>
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: [CDO] Oracle Adapter Wanted [message #663846 is a reply to message #662420] |
Wed, 06 April 2011 15:25 |
Eclipse User |
|
|
|
Originally posted by: info.dav85.de
Hey Guys,
I am currently implement a DBAdapter for Oracle. The adapter works fine,
but in some cases I need do modify something in the CDO Schema. The
problem is, that the CDO Schema contains keywords from Oracle, e.g
..
public static final IDBField COMMIT_INFOS_COMMENT = //
COMMIT_INFOS.addField("comment", DBType.VARCHAR); //$NON-NLS-1$
in this case "comment" is a keyword in oracle and must be renamed.
The other problem that I have at the moment is to write boolean values.
In Oracle boolean is not provided as a datatype. You have to create the
column with the type VARCHAR2(1) or NUMBER(1,0). After that the table
will be created correctly.
But than CDO try to write a value in this column and it crashes with a
SQL Exception
Caused by: java.sql.SQLException: Invalid column type
The reason:
protected void doSetValue(PreparedStatement stmt, int index, Object
value) throws SQLException
{
stmt.setObject(index, value, getSqlType());
}
The function getSqlType() from AbstractTypeMapping returns "BOOLEAN" and
the value is false or true. In Oracle the column has the type
NUMBER(1,0) or VARCHAR(2) and not BOOLEAN and needs a value 1 or 0 or
'Y' or 'N'.
It seems that all other datatypes works fine.
That is current state of my implementation. Tommorrow I'll continue
working on this adapter.
@Eike: Have you some ideas or tips how I can handle this problem?
If the adapter works correctly I can provide it for the CDO Project.
Regards
David
Am 30/03/2011 17:32, schrieb Eike Stepper:
> Hey Guys,
>
> The implementation of the adapter (not the driver) has been accidentally
> deleted by the webmasters:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=270428 . You may want to
> contact Hasan and see if he can find it again on one of his drives. I'd
> be more than happy to review that code and push it through the IP
> clearance at Eclipse.
>
> My personal guess is that a new implementation is not too costly,
> either. I've only been reluctant to do it, because of the flood of
> different JDBC drivers on my box that are needed to entertain all these
> DBs. And I have no experience with Oracle myself. If you look at some of
> the other DBAdapters you'll find out that they do not contain a lot of
> code.
>
> Cheers
> /Eike
>
> ----
> http://www.esc-net.de
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
>
>
>
> Am 30.03.2011 05:22, schrieb Heiko:
>> Hi,
>> at the moment I know only one way, which goes over the CDO Hibernate
>> Store.
>> Examples for this (not direct for an Oracle DB) should you find there:
>> http://dev.eclipse.org/viewcvs/viewvc.cgi/trunk/plugins/?roo t=Modeling_CDO
>>
>>
>> If you following the CDO Source Installation Tutorial (
>> http://wiki.eclipse.org/CDO_Source_Installation ), you would have all
>> needed files in your workspace.
>>
>> At the way over the CDO DB Store, there are only an old bug, but no
>> implementation ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=270428 )
>>
>> Hope it helps
>>
>> Heiko
>>
>> Am 30.03.2011 11:40, schrieb David Skogan:
>>> Hi,
>>>
>>> Could someone please provide information about how to connect to a
>>> oracle database over CDO.
>>> Source code or examples would be nice.
>>>
>>> Regards
>>> David
>>
|
|
| |
Re: [CDO] Oracle Adapter Wanted [message #663863 is a reply to message #663846] |
Wed, 06 April 2011 16:10 |
|
Am 06.04.2011 17:25, schrieb David Hein:
> Hey Guys,
>
> I am currently implement a DBAdapter for Oracle. The adapter works fine,
Good news ;-)
> but in some cases I need do modify something in the CDO Schema. The problem is, that the CDO Schema contains keywords from Oracle, e.g
> .
> public static final IDBField COMMIT_INFOS_COMMENT = //
> COMMIT_INFOS.addField("comment", DBType.VARCHAR); //$NON-NLS-1$
>
> in this case "comment" is a keyword in oracle and must be renamed.
I think we can rename it in CDO.
>
> The other problem that I have at the moment is to write boolean values. In Oracle boolean is not provided as a datatype.
Thank you, Oracle!!!
> You have to create the column with the type VARCHAR2(1) or NUMBER(1,0). After that the table will be created correctly.
> But than CDO try to write a value in this column and it crashes with a SQL Exception
>
> Caused by: java.sql.SQLException: Invalid column type
>
> The reason:
>
> protected void doSetValue(PreparedStatement stmt, int index, Object value) throws SQLException
> {
> stmt.setObject(index, value, getSqlType());
> }
>
> The function getSqlType() from AbstractTypeMapping returns "BOOLEAN" and the value is false or true. In Oracle the column has the type NUMBER(1,0) or VARCHAR(2) and not BOOLEAN and needs a value 1 or 0 or 'Y' or 'N'.
>
> It seems that all other datatypes works fine.
>
> That is current state of my implementation. Tommorrow I'll continue working on this adapter.
>
> @Eike: Have you some ideas or tips how I can handle this problem?
I suspect we need to default to a different TypeMapping with Oracle. Stefan, what do you think?
>
> If the adapter works correctly I can provide it for the CDO Project.
That would be awesome! When you're ready, please submit an enhancement request and attach your code. Maybe we can get it through the IP clearance process for Indigo.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
>
> Regards
> David
>
>
> Am 30/03/2011 17:32, schrieb Eike Stepper:
>> Hey Guys,
>>
>> The implementation of the adapter (not the driver) has been accidentally
>> deleted by the webmasters:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=270428 . You may want to
>> contact Hasan and see if he can find it again on one of his drives. I'd
>> be more than happy to review that code and push it through the IP
>> clearance at Eclipse.
>>
>> My personal guess is that a new implementation is not too costly,
>> either. I've only been reluctant to do it, because of the flood of
>> different JDBC drivers on my box that are needed to entertain all these
>> DBs. And I have no experience with Oracle myself. If you look at some of
>> the other DBAdapters you'll find out that they do not contain a lot of
>> code.
>>
>> Cheers
>> /Eike
>>
>> ----
>> http://www.esc-net.de
>> http://thegordian.blogspot.com
>> http://twitter.com/eikestepper
>>
>>
>>
>> Am 30.03.2011 05:22, schrieb Heiko:
>>> Hi,
>>> at the moment I know only one way, which goes over the CDO Hibernate
>>> Store.
>>> Examples for this (not direct for an Oracle DB) should you find there:
>>> http://dev.eclipse.org/viewcvs/viewvc.cgi/trunk/plugins/?roo t=Modeling_CDO
>>>
>>>
>>> If you following the CDO Source Installation Tutorial (
>>> http://wiki.eclipse.org/CDO_Source_Installation ), you would have all
>>> needed files in your workspace.
>>>
>>> At the way over the CDO DB Store, there are only an old bug, but no
>>> implementation ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=270428 )
>>>
>>> Hope it helps
>>>
>>> Heiko
>>>
>>> Am 30.03.2011 11:40, schrieb David Skogan:
>>>> Hi,
>>>>
>>>> Could someone please provide information about how to connect to a
>>>> oracle database over CDO.
>>>> Source code or examples would be nice.
>>>>
>>>> Regards
>>>> David
>>>
>
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
| |
Re: [CDO] Oracle Adapter Wanted [message #664019 is a reply to message #663863] |
Thu, 07 April 2011 08:26 |
Stefan Winkler Messages: 307 Registered: July 2009 Location: Germany |
Senior Member |
|
|
Hi,
see below.
Am 06.04.11 18:10, schrieb Eike Stepper:
>> You have to create the column with the type VARCHAR2(1) or
>> NUMBER(1,0). After that the table will be created correctly.
>> But than CDO try to write a value in this column and it crashes with a
>> SQL Exception
>>
>> Caused by: java.sql.SQLException: Invalid column type
>>
>> The reason:
>>
>> protected void doSetValue(PreparedStatement stmt, int index, Object
>> value) throws SQLException
>> {
>> stmt.setObject(index, value, getSqlType());
>> }
>>
>> The function getSqlType() from AbstractTypeMapping returns "BOOLEAN"
>> and the value is false or true. In Oracle the column has the type
>> NUMBER(1,0) or VARCHAR(2) and not BOOLEAN and needs a value 1 or 0 or
>> 'Y' or 'N'.
>>
>> It seems that all other datatypes works fine.
>>
>> That is current state of my implementation. Tommorrow I'll continue
>> working on this adapter.
>>
>> @Eike: Have you some ideas or tips how I can handle this problem?
> I suspect we need to default to a different TypeMapping with Oracle.
> Stefan, what do you think?
>
I just had a look into the CoreTypeMappings source and there's already a
mapping from Boolean to Smallint. Maybe you can try that first before
adding a new type mapping.
To map a boolean to smallint you could implement
DBAdapter.adaptType
this method does database-specific type overrides. If you implement it like
DBType adaptType(DBType in) {
return in == DBType.BOOLEAN ? DBType.SMALLINT : in;
}
the EBoolean should be mapped to SMALLINT and the already existing
smallint type mapping should kick in and do the mapping for you.
Cheers,
Stefan
|
|
|
Re: [CDO] Oracle Adapter Wanted [message #664026 is a reply to message #663864] |
Thu, 07 April 2011 08:34 |
Stefan Winkler Messages: 307 Registered: July 2009 Location: Germany |
Senior Member |
|
|
Hi,
Am 06.04.11 18:11, schrieb Eike Stepper:
> Am 06.04.2011 17:51, schrieb Tom Schindl:
>> Am 06.04.11 17:25, schrieb David Hein:
>>> Hey Guys,
>>>
>>> I am currently implement a DBAdapter for Oracle. The adapter works fine,
>>> but in some cases I need do modify something in the CDO Schema. The
>>> problem is, that the CDO Schema contains keywords from Oracle, e.g
>>> .
>>> public static final IDBField COMMIT_INFOS_COMMENT = //
>>> COMMIT_INFOS.addField("comment", DBType.VARCHAR); //$NON-NLS-1$
>>>
>>> in this case "comment" is a keyword in oracle and must be renamed.
>> Well all you need to do is to quote it and then you can even use
>> reserved words in oracle (and most other databases).
>>
>> So if you use
>> COMMIT_INFOS.addField("\\"comment\\"",DBType.VARCHAR) it should work not?
> Sounds good. We'll try it. Thanks!
Problem is that the quoting character is DB-dependent. Some use single
quotes, some use double quotes and some use back-ticks.
There is an open bug
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=306356) addressing the
quoting issue. It's somewhere on my todo list ...
Cheers,
Stefan
|
|
|
Re: [CDO] Oracle Adapter Wanted [message #664043 is a reply to message #664019] |
Thu, 07 April 2011 09:12 |
Eclipse User |
|
|
|
Originally posted by: info.dav85.de
Am 07/04/2011 10:26, schrieb Stefan Winkler:
> Hi,
>
> see below.
>
> Am 06.04.11 18:10, schrieb Eike Stepper:
>
>>> You have to create the column with the type VARCHAR2(1) or
>>> NUMBER(1,0). After that the table will be created correctly.
>>> But than CDO try to write a value in this column and it crashes with a
>>> SQL Exception
>>>
>>> Caused by: java.sql.SQLException: Invalid column type
>>>
>>> The reason:
>>>
>>> protected void doSetValue(PreparedStatement stmt, int index, Object
>>> value) throws SQLException
>>> {
>>> stmt.setObject(index, value, getSqlType());
>>> }
>>>
>>> The function getSqlType() from AbstractTypeMapping returns "BOOLEAN"
>>> and the value is false or true. In Oracle the column has the type
>>> NUMBER(1,0) or VARCHAR(2) and not BOOLEAN and needs a value 1 or 0 or
>>> 'Y' or 'N'.
>>>
>>> It seems that all other datatypes works fine.
>>>
>>> That is current state of my implementation. Tommorrow I'll continue
>>> working on this adapter.
>>>
>>> @Eike: Have you some ideas or tips how I can handle this problem?
>> I suspect we need to default to a different TypeMapping with Oracle.
>> Stefan, what do you think?
>>
>
> I just had a look into the CoreTypeMappings source and there's already a
> mapping from Boolean to Smallint. Maybe you can try that first before
> adding a new type mapping.
>
> To map a boolean to smallint you could implement
> DBAdapter.adaptType
> this method does database-specific type overrides. If you implement it like
>
> DBType adaptType(DBType in) {
> return in == DBType.BOOLEAN ? DBType.SMALLINT : in;
> }
>
> the EBoolean should be mapped to SMALLINT and the already existing
> smallint type mapping should kick in and do the mapping for you.
>
> Cheers,
> Stefan
>
Thank you very much! With this method and the mapping to SMALLINT the
ORACLE Driver writes "BOOLEAN" (VARCHAR(2)) values in the table. :)
Yesterday I was to frustrated to found this method. :-D
Now I will test it with my complete ecore models. If the tests are
successful i will do some refactoring, because there is a lot of debug
code and than I create an enhancement for the oracle db adapter.
|
|
|
Re: [CDO] Oracle Adapter Wanted [message #664044 is a reply to message #664026] |
Thu, 07 April 2011 09:30 |
Eclipse User |
|
|
|
Originally posted by: info.dav85.de
Am 07/04/2011 10:34, schrieb Stefan Winkler:
> Hi,
>
> Am 06.04.11 18:11, schrieb Eike Stepper:
>> Am 06.04.2011 17:51, schrieb Tom Schindl:
>>> Am 06.04.11 17:25, schrieb David Hein:
>>>> Hey Guys,
>>>>
>>>> I am currently implement a DBAdapter for Oracle. The adapter works
>>>> fine,
>>>> but in some cases I need do modify something in the CDO Schema. The
>>>> problem is, that the CDO Schema contains keywords from Oracle, e.g
>>>> .
>>>> public static final IDBField COMMIT_INFOS_COMMENT = //
>>>> COMMIT_INFOS.addField("comment", DBType.VARCHAR); //$NON-NLS-1$
>>>>
>>>> in this case "comment" is a keyword in oracle and must be renamed.
>>> Well all you need to do is to quote it and then you can even use
>>> reserved words in oracle (and most other databases).
>>>
>>> So if you use
>>> COMMIT_INFOS.addField("\\"comment\\"",DBType.VARCHAR) it should work
>>> not?
>> Sounds good. We'll try it. Thanks!
>
> Problem is that the quoting character is DB-dependent. Some use single
> quotes, some use double quotes and some use back-ticks.
>
> There is an open bug
> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=306356) addressing the
> quoting issue. It's somewhere on my todo list ...
>
> Cheers,
> Stefan
I have test it with double quotes and it works with oracle. What is the
current state of this bug?
Cheers,
David
|
|
| | | | | | | | | | | | | | |
Goto Forum:
Current Time: Thu Sep 26 00:31:38 GMT 2024
Powered by FUDForum. Page generated in 0.05957 seconds
|