Reflection to avoid compile dependency

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Reflection to avoid compile dependency

John Hurst-2
Matthias,

I've noticed this datatype-by-reflection design in DbUnit, and understand how it avoids the need for a compile-time dependency.

Where I work we use Oracle but have implemented our own data type factory for it, to handle several custom types not supported by DbUnit. However, we coded it normally with the dependency in our project.

Is everyone comfortable with the reflection solution that DbUnit applies to the problem? Are there any alternatives? As well as being rather verbose, it could potentially result in unnecessarily poor performance. I'd like to contribute further database-specific support to DbUnit (specifically Oracle INTERVAL types), but am not inclined to write the awkward reflection-style code, because in my opinion it's not best practice.

What are your thoughts?

Regards

John Hurst
Wellington, New Zealand

On Thu, Sep 3, 2009 at 8:44 AM, Matthias Gommeringer <[hidden email]> wrote:
Puh, that's a good question. dbunit seems to not support oracle ROWIDs yet. You are very welcome to create a feature request in the sourceforge tracker and implement a corresponding datatype to support the ROWID (please note that you should use reflection for this so that we do not have a compile time dependency in dbunit). As a quick fix could you remove the ROWID from the materialized view?

rgds,
matthias


> -----Ursprüngliche Nachricht-----
> Von: "Bing He" <[hidden email]>
> Gesendet: 02.09.09 21:29:13
> Betreff: Re: [dbunit-user] PROPERTY_TABLE_TYPE


> Thanks so much for your quick response John and Matthias.
>
> I just tried with the syntax and got the following exception. Should I
> log a jira:))????
>
> org.dbunit.dataset.DataSetException: table=LINES_ITEMS_MV, row=0,
> column=LI_RID, value=oracle.sql.ROWID@267e7c
>       at org.dbunit.dataset.xml.FlatXmlWriter.row(FlatXmlWriter.java:217)
>       at org.dbunit.dataset.stream.DataSetProducerAdapter.produce(DataSetProducerAdapter.java:104)
>       at org.dbunit.dataset.xml.FlatXmlWriter.write(FlatXmlWriter.java:124)
>       at org.dbunit.dataset.xml.FlatXmlDataSet.write(FlatXmlDataSet.java:341)
>       at play.IReportDataSetGen.exportData(IReportDataSetGen.java:68)
>       at play.IReportDataSetGen.testRateTypeOrdinal(IReportDataSetGen.java:108)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:585)
>       at junit.framework.TestCase.runTest(TestCase.java:168)
>       at junit.framework.TestCase.runBare(TestCase.java:134)
>       at junit.framework.TestResult$1.protect(TestResult.java:110)
>       at junit.framework.TestResult.runProtected(TestResult.java:128)
>       at junit.framework.TestResult.run(TestResult.java:113)
>       at junit.framework.TestCase.run(TestCase.java:124)
>       at junit.framework.TestSuite.runTest(TestSuite.java:232)
>       at junit.framework.TestSuite.run(TestSuite.java:227)
>       at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
>       at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
>       at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: org.dbunit.dataset.datatype.TypeCastException: Unable to
> typecast value <oracle.sql.ROWID@267e7c> of type <oracle.sql.ROWID> to
> VARCHAR
>       at org.dbunit.dataset.datatype.StringDataType.typeCast(StringDataType.java:132)
>       at org.dbunit.dataset.datatype.DataType.asString(DataType.java:159)
>       at org.dbunit.dataset.xml.FlatXmlWriter.row(FlatXmlWriter.java:212)
>       ... 24 more
>
>
>
> On Wed, Sep 2, 2009 at 2:20 PM, John Hurst<[hidden email]> wrote:
> > Whoops, I didn't understand the question. Sorry about that.
> >
> > John Hurst
> >
> > On Sep 3, 2009 7:16 AM, "Matthias Gommeringer" <[hidden email]>
> > wrote:
> >
> > This should do the job, at least for loading:
> >
> >        DatabaseConnection conn = new DatabaseConnection(...);
> >        String[] types = new String[]{"TABLE", "VIEW", "MATERIALIZED VIEW"};
> >        conn.getConfig().setProperty(DatabaseConfig.PROPERTY_TABLE_TYPE,
> > types);
> >
> > HTH
> > rgds,
> > matthias
> >
> >> -----Ursprüngliche Nachricht-----
> >> Von: "Bing He" <[hidden email]>
> >> Gesendet: 02.09.09 17:34:54
> >> An: [hidden email]
> >> Betreff: [dbunit-user] PROPERTY_TABLE_TYPE
> >
> >> Team, can anyone show me how to use the argument to setup >
> >> PROPERTY_TABLE_TYPE to view or mater...
> >
> > ______________________________________________________
> > GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
> > Jetzt freischalten unter http://movieflat.web.de
> >
> > ------------------------------------------------------------------------------
> > Let Crystal Reports...
> >
> > ------------------------------------------------------------------------------
> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> > trial. Simplify your report design, integration and deployment - and focus
> > on
> > what you do best, core application coding. Discover what's new with
> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> > _______________________________________________
> > dbunit-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >
> >
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>


______________________________________________________
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user



--
COH: Level 10 US

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Reflection to avoid compile dependency

Zdenek Vrablik
Hi All,

I have implemented support for SDO_GEOMETRY recently. I haven't
submitted the code yet.

I wouldn't like use reflection. The code is not readable and it would
cause performance issues.

I would recommend split dbUnit into modules one general + one module
per database.

Maven 2 does support this modularization very well. I am able to help with this.
I have never used profiles, but seems like defining special profile
for databases which doesn't have publicly available
jdbc drivers.

Other option may be implement mock object with same packages, class
names and public methods. This jar file could be used for compilation
and will be replaced with the implementation later if necessary. I am
not sure if this way is legal.

What do you think about it?

Regards,
Zdenek

On Thu, Sep 3, 2009 at 12:53 AM, John Hurst<[hidden email]> wrote:

> Matthias,
>
> I've noticed this datatype-by-reflection design in DbUnit, and understand
> how it avoids the need for a compile-time dependency.
>
> Where I work we use Oracle but have implemented our own data type factory
> for it, to handle several custom types not supported by DbUnit. However, we
> coded it normally with the dependency in our project.
>
> Is everyone comfortable with the reflection solution that DbUnit applies to
> the problem? Are there any alternatives? As well as being rather verbose, it
> could potentially result in unnecessarily poor performance. I'd like to
> contribute further database-specific support to DbUnit (specifically Oracle
> INTERVAL types), but am not inclined to write the awkward reflection-style
> code, because in my opinion it's not best practice.
>
> What are your thoughts?
>
> Regards
>
> John Hurst
> Wellington, New Zealand
>
> On Thu, Sep 3, 2009 at 8:44 AM, Matthias Gommeringer
> <[hidden email]> wrote:
>>
>> Puh, that's a good question. dbunit seems to not support oracle ROWIDs
>> yet. You are very welcome to create a feature request in the sourceforge
>> tracker and implement a corresponding datatype to support the ROWID (please
>> note that you should use reflection for this so that we do not have a
>> compile time dependency in dbunit). As a quick fix could you remove the
>> ROWID from the materialized view?
>>
>> rgds,
>> matthias
>>
>>
>> > -----Ursprüngliche Nachricht-----
>> > Von: "Bing He" <[hidden email]>
>> > Gesendet: 02.09.09 21:29:13
>> > An: [hidden email]
>> > Betreff: Re: [dbunit-user] PROPERTY_TABLE_TYPE
>>
>>
>> > Thanks so much for your quick response John and Matthias.
>> >
>> > I just tried with the syntax and got the following exception. Should I
>> > log a jira:))????
>> >
>> > org.dbunit.dataset.DataSetException: table=LINES_ITEMS_MV, row=0,
>> > column=LI_RID, value=oracle.sql.ROWID@267e7c
>> >       at
>> > org.dbunit.dataset.xml.FlatXmlWriter.row(FlatXmlWriter.java:217)
>> >       at
>> > org.dbunit.dataset.stream.DataSetProducerAdapter.produce(DataSetProducerAdapter.java:104)
>> >       at
>> > org.dbunit.dataset.xml.FlatXmlWriter.write(FlatXmlWriter.java:124)
>> >       at
>> > org.dbunit.dataset.xml.FlatXmlDataSet.write(FlatXmlDataSet.java:341)
>> >       at play.IReportDataSetGen.exportData(IReportDataSetGen.java:68)
>> >       at
>> > play.IReportDataSetGen.testRateTypeOrdinal(IReportDataSetGen.java:108)
>> >       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> >       at
>> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> >       at
>> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> >       at java.lang.reflect.Method.invoke(Method.java:585)
>> >       at junit.framework.TestCase.runTest(TestCase.java:168)
>> >       at junit.framework.TestCase.runBare(TestCase.java:134)
>> >       at junit.framework.TestResult$1.protect(TestResult.java:110)
>> >       at junit.framework.TestResult.runProtected(TestResult.java:128)
>> >       at junit.framework.TestResult.run(TestResult.java:113)
>> >       at junit.framework.TestCase.run(TestCase.java:124)
>> >       at junit.framework.TestSuite.runTest(TestSuite.java:232)
>> >       at junit.framework.TestSuite.run(TestSuite.java:227)
>> >       at
>> > org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
>> >       at
>> > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
>> >       at
>> > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>> >       at
>> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>> >       at
>> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>> >       at
>> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>> >       at
>> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
>> > Caused by: org.dbunit.dataset.datatype.TypeCastException: Unable to
>> > typecast value <oracle.sql.ROWID@267e7c> of type <oracle.sql.ROWID> to
>> > VARCHAR
>> >       at
>> > org.dbunit.dataset.datatype.StringDataType.typeCast(StringDataType.java:132)
>> >       at
>> > org.dbunit.dataset.datatype.DataType.asString(DataType.java:159)
>> >       at
>> > org.dbunit.dataset.xml.FlatXmlWriter.row(FlatXmlWriter.java:212)
>> >       ... 24 more
>> >
>> >
>> >
>> > On Wed, Sep 2, 2009 at 2:20 PM, John Hurst<[hidden email]>
>> > wrote:
>> > > Whoops, I didn't understand the question. Sorry about that.
>> > >
>> > > John Hurst
>> > >
>> > > On Sep 3, 2009 7:16 AM, "Matthias Gommeringer"
>> > > <[hidden email]>
>> > > wrote:
>> > >
>> > > This should do the job, at least for loading:
>> > >
>> > >        DatabaseConnection conn = new DatabaseConnection(...);
>> > >        String[] types = new String[]{"TABLE", "VIEW", "MATERIALIZED
>> > > VIEW"};
>> > >
>> > >  conn.getConfig().setProperty(DatabaseConfig.PROPERTY_TABLE_TYPE,
>> > > types);
>> > >
>> > > HTH
>> > > rgds,
>> > > matthias
>> > >
>> > >> -----Ursprüngliche Nachricht-----
>> > >> Von: "Bing He" <[hidden email]>
>> > >> Gesendet: 02.09.09 17:34:54
>> > >> An: [hidden email]
>> > >> Betreff: [dbunit-user] PROPERTY_TABLE_TYPE
>> > >
>> > >> Team, can anyone show me how to use the argument to setup >
>> > >> PROPERTY_TABLE_TYPE to view or mater...
>> > >
>> > > ______________________________________________________
>> > > GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
>> > > Jetzt freischalten unter http://movieflat.web.de
>> > >
>> > >
>> > > ------------------------------------------------------------------------------
>> > > Let Crystal Reports...
>> > >
>> > >
>> > > ------------------------------------------------------------------------------
>> > > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> > > 30-Day
>> > > trial. Simplify your report design, integration and deployment - and
>> > > focus
>> > > on
>> > > what you do best, core application coding. Discover what's new with
>> > > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> > > _______________________________________________
>> > > dbunit-user mailing list
>> > > [hidden email]
>> > > https://lists.sourceforge.net/lists/listinfo/dbunit-user
>> > >
>> > >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> > 30-Day
>> > trial. Simplify your report design, integration and deployment - and
>> > focus on
>> > what you do best, core application coding. Discover what's new with
>> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> > _______________________________________________
>> > dbunit-user mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
>> >
>>
>>
>> ______________________________________________________
>> GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
>> Jetzt freischalten unter http://movieflat.web.de
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> 30-Day
>> trial. Simplify your report design, integration and deployment - and focus
>> on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> dbunit-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>
>
>
> --
> COH: Level 10 US
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Reflection to avoid compile dependency

Matthias Gommeringer
In reply to this post by John Hurst-2
Hi John, Zdenek,

actually dbunit uses reflection code because the ojdbc.jar is not publicly available via a maven repository (as you already mentioned).

First of all I also prefer a solution without reflection but reflection is currently the simplest way to keep the code together. Splitting dbunit into modules is still a bit effort but if one of you will do this task I'll ask roberto to add you as a dbunit committer.

I'd definitely prefer Zdenek's first proposal and _not_ implement mocks for jdbc driver functions. This would probably lead to cluttered and redundant code in my opinion. We could also start with the modularisation using oracle as an example and then step by step migrating other datatype factories on the same way.

Nevertheless the reflection way is currently very convenient although error prone. With respect to performance I believe that the overhead is not that performance huge anymore, at least since java 5 came.

Please let me know what you think,
matthias

> -----Ursprüngliche Nachricht-----
> Von: "Zdeněk Vráblík" <[hidden email]>
> Gesendet: 03.09.09 15:09:33
> An: [hidden email]
> Betreff: Re: [dbunit-user] Reflection to avoid compile dependency


> Hi All,
>
> I have implemented support for SDO_GEOMETRY recently. I haven't
> submitted the code yet.
>
> I wouldn't like use reflection. The code is not readable and it would
> cause performance issues.
>
> I would recommend split dbUnit into modules one general + one module
> per database.
>
> Maven 2 does support this modularization very well. I am able to help with this.
> I have never used profiles, but seems like defining special profile
> for databases which doesn't have publicly available
> jdbc drivers.
>
> Other option may be implement mock object with same packages, class
> names and public methods. This jar file could be used for compilation
> and will be replaced with the implementation later if necessary. I am
> not sure if this way is legal.
>
> What do you think about it?
>
> Regards,
> Zdenek
>
> On Thu, Sep 3, 2009 at 12:53 AM, John Hurst<[hidden email]> wrote:
> > Matthias,
> >
> > I've noticed this datatype-by-reflection design in DbUnit, and understand
> > how it avoids the need for a compile-time dependency.
> >
> > Where I work we use Oracle but have implemented our own data type factory
> > for it, to handle several custom types not supported by DbUnit. However, we
> > coded it normally with the dependency in our project.
> >
> > Is everyone comfortable with the reflection solution that DbUnit applies to
> > the problem? Are there any alternatives? As well as being rather verbose, it
> > could potentially result in unnecessarily poor performance. I'd like to
> > contribute further database-specific support to DbUnit (specifically Oracle
> > INTERVAL types), but am not inclined to write the awkward reflection-style
> > code, because in my opinion it's not best practice.
> >
> > What are your thoughts?
> >
> > Regards
> >
> > John Hurst
> > Wellington, New Zealand
> >
> > On Thu, Sep 3, 2009 at 8:44 AM, Matthias Gommeringer
> > <[hidden email]> wrote:
> >>
> >> Puh, that's a good question. dbunit seems to not support oracle ROWIDs
> >> yet. You are very welcome to create a feature request in the sourceforge
> >> tracker and implement a corresponding datatype to support the ROWID (please
> >> note that you should use reflection for this so that we do not have a
> >> compile time dependency in dbunit). As a quick fix could you remove the
> >> ROWID from the materialized view?
> >>
> >> rgds,
> >> matthias
> >>
> >>
> >> > -----Ursprüngliche Nachricht-----
> >> > Von: "Bing He" <[hidden email]>
> >> > Gesendet: 02.09.09 21:29:13
> >> > An: [hidden email]
> >> > Betreff: Re: [dbunit-user] PROPERTY_TABLE_TYPE
> >>
> >>
> >> > Thanks so much for your quick response John and Matthias.
> >> >
> >> > I just tried with the syntax and got the following exception. Should I
> >> > log a jira:))????
> >> >
> >> > org.dbunit.dataset.DataSetException: table=LINES_ITEMS_MV, row=0,
> >> > column=LI_RID, value=oracle.sql.ROWID@267e7c
> >> >       at
> >> > org.dbunit.dataset.xml.FlatXmlWriter.row(FlatXmlWriter.java:217)
> >> >       at
> >> > org.dbunit.dataset.stream.DataSetProducerAdapter.produce(DataSetProducerAdapter.java:104)
> >> >       at
> >> > org.dbunit.dataset.xml.FlatXmlWriter.write(FlatXmlWriter.java:124)
> >> >       at
> >> > org.dbunit.dataset.xml.FlatXmlDataSet.write(FlatXmlDataSet.java:341)
> >> >       at play.IReportDataSetGen.exportData(IReportDataSetGen.java:68)
> >> >       at
> >> > play.IReportDataSetGen.testRateTypeOrdinal(IReportDataSetGen.java:108)
> >> >       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >> >       at
> >> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >> >       at
> >> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >       at java.lang.reflect.Method.invoke(Method.java:585)
> >> >       at junit.framework.TestCase.runTest(TestCase.java:168)
> >> >       at junit.framework.TestCase.runBare(TestCase.java:134)
> >> >       at junit.framework.TestResult$1.protect(TestResult.java:110)
> >> >       at junit.framework.TestResult.runProtected(TestResult.java:128)
> >> >       at junit.framework.TestResult.run(TestResult.java:113)
> >> >       at junit.framework.TestCase.run(TestCase.java:124)
> >> >       at junit.framework.TestSuite.runTest(TestSuite.java:232)
> >> >       at junit.framework.TestSuite.run(TestSuite.java:227)
> >> >       at
> >> > org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
> >> >       at
> >> > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
> >> >       at
> >> > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> >> >       at
> >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> >> >       at
> >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> >> >       at
> >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> >> >       at
> >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> >> > Caused by: org.dbunit.dataset.datatype.TypeCastException: Unable to
> >> > typecast value <oracle.sql.ROWID@267e7c> of type <oracle.sql.ROWID> to
> >> > VARCHAR
> >> >       at
> >> > org.dbunit.dataset.datatype.StringDataType.typeCast(StringDataType.java:132)
> >> >       at
> >> > org.dbunit.dataset.datatype.DataType.asString(DataType.java:159)
> >> >       at
> >> > org.dbunit.dataset.xml.FlatXmlWriter.row(FlatXmlWriter.java:212)
> >> >       ... 24 more
> >> >
> >> >
> >> >
> >> > On Wed, Sep 2, 2009 at 2:20 PM, John Hurst<[hidden email]>
> >> > wrote:
> >> > > Whoops, I didn't understand the question. Sorry about that.
> >> > >
> >> > > John Hurst
> >> > >
> >> > > On Sep 3, 2009 7:16 AM, "Matthias Gommeringer"
> >> > > <[hidden email]>
> >> > > wrote:
> >> > >
> >> > > This should do the job, at least for loading:
> >> > >
> >> > >        DatabaseConnection conn = new DatabaseConnection(...);
> >> > >        String[] types = new String[]{"TABLE", "VIEW", "MATERIALIZED
> >> > > VIEW"};
> >> > >
> >> > >  conn.getConfig().setProperty(DatabaseConfig.PROPERTY_TABLE_TYPE,
> >> > > types);
> >> > >
> >> > > HTH
> >> > > rgds,
> >> > > matthias
> >> > >
> >> > >> -----Ursprüngliche Nachricht-----
> >> > >> Von: "Bing He" <[hidden email]>
> >> > >> Gesendet: 02.09.09 17:34:54
> >> > >> An: [hidden email]
> >> > >> Betreff: [dbunit-user] PROPERTY_TABLE_TYPE
> >> > >
> >> > >> Team, can anyone show me how to use the argument to setup >
> >> > >> PROPERTY_TABLE_TYPE to view or mater...
> >> > >
> >> > > ______________________________________________________
> >> > > GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
> >> > > Jetzt freischalten unter http://movieflat.web.de
> >> > >
> >> > >
> >> > > ------------------------------------------------------------------------------
> >> > > Let Crystal Reports...
> >> > >
> >> > >
> >> > > ------------------------------------------------------------------------------
> >> > > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> > > 30-Day
> >> > > trial. Simplify your report design, integration and deployment - and
> >> > > focus
> >> > > on
> >> > > what you do best, core application coding. Discover what's new with
> >> > > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> > > _______________________________________________
> >> > > dbunit-user mailing list
> >> > > [hidden email]
> >> > > https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >> > >
> >> > >
> >> >
> >> >
> >> > ------------------------------------------------------------------------------
> >> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> > 30-Day
> >> > trial. Simplify your report design, integration and deployment - and
> >> > focus on
> >> > what you do best, core application coding. Discover what's new with
> >> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> > _______________________________________________
> >> > dbunit-user mailing list
> >> > [hidden email]
> >> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >> >
> >>
> >>
> >> ______________________________________________________
> >> GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
> >> Jetzt freischalten unter http://movieflat.web.de
> >>
> >>
> >>
> >> ------------------------------------------------------------------------------
> >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> 30-Day
> >> trial. Simplify your report design, integration and deployment - and focus
> >> on
> >> what you do best, core application coding. Discover what's new with
> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> _______________________________________________
> >> dbunit-user mailing list
> >> [hidden email]
> >> https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >
> >
> >
> > --
> > COH: Level 10 US
> >
> > ------------------------------------------------------------------------------
> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> > trial. Simplify your report design, integration and deployment - and focus
> > on
> > what you do best, core application coding. Discover what's new with
> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> > _______________________________________________
> > dbunit-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >
> >
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>


______________________________________________________
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Reflection to avoid compile dependency

John Hurst-2
I'm hoping to spend some time hacking on DbUnit today. If I get far enough into it, I'll see whether I can implement the Maven profile idea.

It seems that if one wants to build a Maven project including a dependency on something like ojdbc14.jar, one has to add it manually to a local repository. Not very difficult, but should not be part of the default DbUnit build. It would be acceptable, I think, on an "optional" build.

I'll move over to the dev list with the discussion if I get anywhere...

Regards

John Hurst

On Fri, Sep 4, 2009 at 8:12 AM, Matthias Gommeringer <[hidden email]> wrote:
Hi John, Zdenek,

actually dbunit uses reflection code because the ojdbc.jar is not publicly available via a maven repository (as you already mentioned).

First of all I also prefer a solution without reflection but reflection is currently the simplest way to keep the code together. Splitting dbunit into modules is still a bit effort but if one of you will do this task I'll ask roberto to add you as a dbunit committer.

I'd definitely prefer Zdenek's first proposal and _not_ implement mocks for jdbc driver functions. This would probably lead to cluttered and redundant code in my opinion. We could also start with the modularisation using oracle as an example and then step by step migrating other datatype factories on the same way.

Nevertheless the reflection way is currently very convenient although error prone. With respect to performance I believe that the overhead is not that performance huge anymore, at least since java 5 came.

Please let me know what you think,
matthias

> -----Ursprüngliche Nachricht-----
> Von: "ZdenÄ k Vráblík" <[hidden email]>
> Gesendet: 03.09.09 15:09:33
> Betreff: Re: [dbunit-user] Reflection to avoid compile dependency


> Hi All,
>
> I have implemented support for SDO_GEOMETRY recently. I haven't
> submitted the code yet.
>
> I wouldn't like use reflection. The code is not readable and it would
> cause performance issues.
>
> I would recommend split dbUnit into modules one general + one module
> per database.
>
> Maven 2 does support this modularization very well. I am able to help with this.
> I have never used profiles, but seems like defining special profile
> for databases which doesn't have publicly available
> jdbc drivers.
>
> Other option may be implement mock object with same packages, class
> names and public methods. This jar file could be used for compilation
> and will be replaced with the implementation later if necessary. I am
> not sure if this way is legal.
>
> What do you think about it?
>
> Regards,
> Zdenek
>
> On Thu, Sep 3, 2009 at 12:53 AM, John Hurst<[hidden email]> wrote:
> > Matthias,
> >
> > I've noticed this datatype-by-reflection design in DbUnit, and understand
> > how it avoids the need for a compile-time dependency.
> >
> > Where I work we use Oracle but have implemented our own data type factory
> > for it, to handle several custom types not supported by DbUnit. However, we
> > coded it normally with the dependency in our project.
> >
> > Is everyone comfortable with the reflection solution that DbUnit applies to
> > the problem? Are there any alternatives? As well as being rather verbose, it
> > could potentially result in unnecessarily poor performance. I'd like to
> > contribute further database-specific support to DbUnit (specifically Oracle
> > INTERVAL types), but am not inclined to write the awkward reflection-style
> > code, because in my opinion it's not best practice.
> >
> > What are your thoughts?
> >
> > Regards
> >
> > John Hurst
> > Wellington, New Zealand
> >
> > On Thu, Sep 3, 2009 at 8:44 AM, Matthias Gommeringer
> > <[hidden email]> wrote:
> >>
> >> Puh, that's a good question. dbunit seems to not support oracle ROWIDs
> >> yet. You are very welcome to create a feature request in the sourceforge
> >> tracker and implement a corresponding datatype to support the ROWID (please
> >> note that you should use reflection for this so that we do not have a
> >> compile time dependency in dbunit). As a quick fix could you remove the
> >> ROWID from the materialized view?
> >>
> >> rgds,
> >> matthias
> >>
> >>
> >> > -----Ursprüngliche Nachricht-----
> >> > Von: "Bing He" <[hidden email]>
> >> > Gesendet: 02.09.09 21:29:13
> >> > An: [hidden email]
> >> > Betreff: Re: [dbunit-user] PROPERTY_TABLE_TYPE
> >>
> >>
> >> > Thanks so much for your quick response John and Matthias.
> >> >
> >> > I just tried with the syntax and got the following exception. Should I
> >> > log a jira:))????
> >> >
> >> > org.dbunit.dataset.DataSetException: table=LINES_ITEMS_MV, row=0,
> >> > column=LI_RID, value=oracle.sql.ROWID@267e7c
> >> >       at
> >> > org.dbunit.dataset.xml.FlatXmlWriter.row(FlatXmlWriter.java:217)
> >> >       at
> >> > org.dbunit.dataset.stream.DataSetProducerAdapter.produce(DataSetProducerAdapter.java:104)
> >> >       at
> >> > org.dbunit.dataset.xml.FlatXmlWriter.write(FlatXmlWriter.java:124)
> >> >       at
> >> > org.dbunit.dataset.xml.FlatXmlDataSet.write(FlatXmlDataSet.java:341)
> >> >       at play.IReportDataSetGen.exportData(IReportDataSetGen.java:68)
> >> >       at
> >> > play.IReportDataSetGen.testRateTypeOrdinal(IReportDataSetGen.java:108)
> >> >       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >> >       at
> >> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >> >       at
> >> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >       at java.lang.reflect.Method.invoke(Method.java:585)
> >> >       at junit.framework.TestCase.runTest(TestCase.java:168)
> >> >       at junit.framework.TestCase.runBare(TestCase.java:134)
> >> >       at junit.framework.TestResult$1.protect(TestResult.java:110)
> >> >       at junit.framework.TestResult.runProtected(TestResult.java:128)
> >> >       at junit.framework.TestResult.run(TestResult.java:113)
> >> >       at junit.framework.TestCase.run(TestCase.java:124)
> >> >       at junit.framework.TestSuite.runTest(TestSuite.java:232)
> >> >       at junit.framework.TestSuite.run(TestSuite.java:227)
> >> >       at
> >> > org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
> >> >       at
> >> > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
> >> >       at
> >> > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> >> >       at
> >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> >> >       at
> >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> >> >       at
> >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> >> >       at
> >> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> >> > Caused by: org.dbunit.dataset.datatype.TypeCastException: Unable to
> >> > typecast value <oracle.sql.ROWID@267e7c> of type <oracle.sql.ROWID> to
> >> > VARCHAR
> >> >       at
> >> > org.dbunit.dataset.datatype.StringDataType.typeCast(StringDataType.java:132)
> >> >       at
> >> > org.dbunit.dataset.datatype.DataType.asString(DataType.java:159)
> >> >       at
> >> > org.dbunit.dataset.xml.FlatXmlWriter.row(FlatXmlWriter.java:212)
> >> >       ... 24 more
> >> >
> >> >
> >> >
> >> > On Wed, Sep 2, 2009 at 2:20 PM, John Hurst<[hidden email]>
> >> > wrote:
> >> > > Whoops, I didn't understand the question. Sorry about that.
> >> > >
> >> > > John Hurst
> >> > >
> >> > > On Sep 3, 2009 7:16 AM, "Matthias Gommeringer"
> >> > > <[hidden email]>
> >> > > wrote:
> >> > >
> >> > > This should do the job, at least for loading:
> >> > >
> >> > >        DatabaseConnection conn = new DatabaseConnection(...);
> >> > >        String[] types = new String[]{"TABLE", "VIEW", "MATERIALIZED
> >> > > VIEW"};
> >> > >
> >> > >  conn.getConfig().setProperty(DatabaseConfig.PROPERTY_TABLE_TYPE,
> >> > > types);
> >> > >
> >> > > HTH
> >> > > rgds,
> >> > > matthias
> >> > >
> >> > >> -----Ursprüngliche Nachricht-----
> >> > >> Von: "Bing He" <[hidden email]>
> >> > >> Gesendet: 02.09.09 17:34:54
> >> > >> An: [hidden email]
> >> > >> Betreff: [dbunit-user] PROPERTY_TABLE_TYPE
> >> > >
> >> > >> Team, can anyone show me how to use the argument to setup >
> >> > >> PROPERTY_TABLE_TYPE to view or mater...
> >> > >
> >> > > ______________________________________________________
> >> > > GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
> >> > > Jetzt freischalten unter http://movieflat.web.de
> >> > >
> >> > >
> >> > > ------------------------------------------------------------------------------
> >> > > Let Crystal Reports...
> >> > >
> >> > >
> >> > > ------------------------------------------------------------------------------
> >> > > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> > > 30-Day
> >> > > trial. Simplify your report design, integration and deployment - and
> >> > > focus
> >> > > on
> >> > > what you do best, core application coding. Discover what's new with
> >> > > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> > > _______________________________________________
> >> > > dbunit-user mailing list
> >> > > [hidden email]
> >> > > https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >> > >
> >> > >
> >> >
> >> >
> >> > ------------------------------------------------------------------------------
> >> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> > 30-Day
> >> > trial. Simplify your report design, integration and deployment - and
> >> > focus on
> >> > what you do best, core application coding. Discover what's new with
> >> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> > _______________________________________________
> >> > dbunit-user mailing list
> >> > [hidden email]
> >> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >> >
> >>
> >>
> >> ______________________________________________________
> >> GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
> >> Jetzt freischalten unter http://movieflat.web.de
> >>
> >>
> >>
> >> ------------------------------------------------------------------------------
> >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> >> 30-Day
> >> trial. Simplify your report design, integration and deployment - and focus
> >> on
> >> what you do best, core application coding. Discover what's new with
> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> _______________________________________________
> >> dbunit-user mailing list
> >> [hidden email]
> >> https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >
> >
> >
> > --
> > COH: Level 10 US
> >
> > ------------------------------------------------------------------------------
> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> > trial. Simplify your report design, integration and deployment - and focus
> > on
> > what you do best, core application coding. Discover what's new with
> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> > _______________________________________________
> > dbunit-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/dbunit-user
> >
> >
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>


______________________________________________________
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user



--
COH: Level 10 US

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user