« Return to Thread: Reflection to avoid compile dependency

Re: Reflection to avoid compile dependency

by Zdenek Vrablik :: Rate this Message:

Reply to Author | View in Thread

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<john.b.hurst@...> 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
> <Matthias.Gommeringer@...> 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" <bingsaber@...>
>> > Gesendet: 02.09.09 21:29:13
>> > An: dbunit-user@...
>> > 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<john.b.hurst@...>
>> > wrote:
>> > > Whoops, I didn't understand the question. Sorry about that.
>> > >
>> > > John Hurst
>> > >
>> > > On Sep 3, 2009 7:16 AM, "Matthias Gommeringer"
>> > > <Matthias.Gommeringer@...>
>> > > 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" <bingsaber@...>
>> > >> Gesendet: 02.09.09 17:34:54
>> > >> An: dbunit-user@...
>> > >> 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
>> > > dbunit-user@...
>> > > 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
>> > dbunit-user@...
>> > 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
>> dbunit-user@...
>> 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
> dbunit-user@...
> 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
dbunit-user@...
https://lists.sourceforge.net/lists/listinfo/dbunit-user

 « Return to Thread: Reflection to avoid compile dependency