Hi all,

Thank you Jens for clarifying. I could now reproduce this exception!
The issue is, that the database is not instantiated with a schema name.
I noticed that none of the examples is doing this. If I call the super
constructor of "SampleDB" with a schema name of "public" there is no
exception, but nothing is dropped either. Now, that's even worse :) The
database is obviously happy with this instruction but it won't do what's
expected.

The script that's created by getDDLScript(DBCmdType.DROP, db, script) is
                                                                        
    DROP USER public                                                    

where "public" is the schema name. As Jens already pointed out, that
happens on DBDDLGenerator:219 (v2.4.0). This is probably doing something
else than dropping a database, but syntactically correct as HSQL doesn't
complain.

I suppose that needs to be fixed in either HSqlDDLGenerator or
DBDDLGenerator. I'm not quite sure what to do, but I found some
"inconsistencies":

* DBDDLGenerator has a protected method "dropDatabase" that is unused
  (reported in IDEA) but overriden in OracleDDLGenerator. So maybe line
  219 in DBDDLGenerator should call "dropDatabase" instead? This could
  then be overriden in HSqlDDLGenerator.

* right now line 219 in DBDDLGenerator says
                                           
     dropObject(((DBDatabase) dbo).getSchema(), "USER", script);

  which is exactly how the `dropDatabase` method is overriden in
  OracleDDLGenerator. I suspect this is the correct way to drop a
  database in oracle?

I created a Jira issue for this now:
https://issues.apache.org/jira/browse/EMPIREDB-155

best regards
Eike

On [Thu, 09.08.2012 14:17], [email protected] wrote:
> Hi Eike, hi Francis!
> 
> A) sorry, I did not mention clearly I use Empire in a spring env based on the 
> sample.
> 
> B) I am not dropping tables (this works, but misses to drop sequences, 
> indexes and other constraints), I am dropping a Database. See 
> DBDDLGenerator:218. In case the HSQL DDL generator executes "DROP SCHEMA 
> PUBLIC CASCADE" this might be a workaround. Or maybe the schema name is set 
> to "PUBLIC" on creation time (did not try this honestly)
> 
> C) code: driver.getDDLScript(DBCmdType.DROP, db, script); // db is a 
> DBDatabase
> 
> D) I will download the latest 2.4 and retest. 
> 
> Jens
> 
> Sent from my iPhone
> 
> On 09.08.2012, at 12:43, Eike Kettner <[email protected]> wrote:
> 
> > Hi all,
> > 
> > I'm looking into this today and a few questions popped up :)
> > 
> > At first, I thought it got forgotten to set the schema name into the
> > driver in the EmpireDriverFactory class (as most drivers support this).
> > But I found out that the HSql-driver does not. Unfortunately I don't
> > have any knowledge about HSQL, so I cannot comment this any further. Is
> > it correct for HSQL that its driver is not using a schema name?
> > 
> > I then added DROP TABLE code to the spring example project and started
> > it using HSQL driver. It worked nicely (using the same lines of code
> > Francis showed in his last mail from the DBDatabaseDriverHSqlTest).
> > 
> > @Jens, as Francis already asked, could you provide any stack-trace
> > and/or a bit of code that shows this behaviour?
> > 
> > Best regards
> > Eike
> > 
> > On [Wed, 08.08.2012 22:36], Francis De Brabandere wrote:
> >> Hi Jens,
> >> 
> >> Would you mind creating an issue for this on
> >> https://issues.apache.org/jira/browse/EMPIREDB - so we make sure this
> >> is fixed and tracked in the release notes?
> >> 
> >> Thanks,
> >> Francis
> >> 
> >> On 8 August 2012 16:57, [email protected] <[email protected]> wrote:
> >>> HI Eike!
> >>> 
> >>> I buy this! I started with this sample and in the meantime figured out we 
> >>> can use "DROP SCHEMA PUBLIC CASCADE" in the driver in case it is HSQL and 
> >>> dropping a database is needed.
> >>> 
> >>> A fix will be nice. But I can also try to write my own driver factory 
> >>> class...
> >>> 
> >>> Sent from my iPhone
> >>> 
> >>> On 08.08.2012, at 15:42, Eike Kettner <[email protected]> wrote:
> >>> 
> >>>> Hi,
> >>>> 
> >>>> I think that's a bug in the EmpireDriverFactory class. This class is
> >>>> part of the sample project and was created as an example on how it could
> >>>> work with spring. Well..., do you actually mean this class from the
> >>>> example-spring project?
> >>>> 
> >>>> If so, I would recommend to not depend on this jar file but rather
> >>>> create a new DriverFactory (without that bug :)) class in your project.
> >>>> But, of course, the EmpireDriverFactory class in the samples should be
> >>>> fixed. I can do that the next days.
> >>>> 
> >>>> best regards
> >>>> Eike
> >>>> 
> >>>> On [Wed, 08.08.2012 14:51], [email protected] wrote:
> >>>>> Hi Francis!
> >>>>> 
> >>>>> I digged a bit deeper: the schema name is avail as param in the 
> >>>>> EmpireDriverFactory, but not used at all in case of HSQL (see :65 in 
> >>>>> the factory). This at least explains the IllegalArgumentEx. Any ideas?
> >>>>> 
> >>>>> Jens
> >>>>> 
> >>>>> Sent from my iPhone
> >>>>> 
> >>>>> On 07.08.2012, at 11:44, Francis De Brabandere <[email protected]> 
> >>>>> wrote:
> >>>>> 
> >>>>>> Hi Jens,
> >>>>>> 
> >>>>>> In DBDatabaseDriverHSqlTest this code is in use:
> >>>>>> 
> >>>>>>      script = new DBSQLScript();
> >>>>>>      db.getDriver().getDDLScript(DBCmdType.DROP, db.EMPLOYEE, script);
> >>>>>>      db.getDriver().getDDLScript(DBCmdType.DROP, db.DEPARTMENT, 
> >>>>>> script);
> >>>>>>      script.run(db.getDriver(), conn, true);
> >>>>>> 
> >>>>>> As far as I know this is working correctly, would you mind providing
> >>>>>> us with some stacktrace or test to reproduce your issue? What sources
> >>>>>> are you talking about?
> >>>>>> 
> >>>>>> Cheers,
> >>>>>> Francis
> >>>>>> 
> >>>>>> On 6 August 2012 15:15, [email protected] <[email protected]> 
> >>>>>> wrote:
> >>>>>>> Hi All!
> >>>>>>> 
> >>>>>>> I am working with empire 2.3.0 + spring and got everything working 
> >>>>>>> incl
> >>>>>>> transactions. For testing purposes I want to drop my database (hsql in
> >>>>>>> memory) between test runs. The "database" getCreateDDLScript method 
> >>>>>>> creates
> >>>>>>> all tables and I am looking for a DropDDLScript method but can't 
> >>>>>>> figure it
> >>>>>>> out. The method exists on the driver (OracleDDLGenerator for example) 
> >>>>>>> and I
> >>>>>>> can call it like:
> >>>>>>> db.getDriver().getDDLScript(DBCmdType.DROP,..) but this fails with an
> >>>>>>> exception "Invalid Argument null for parameter name". From the 
> >>>>>>> sources a
> >>>>>>> schema name is missing so I am a little confused..,
> >>>>>>> 
> >>>>>>> Can you point me to the right direction?
> >>>>>>> Thx in advance
> >>>>>>> 
> >>>>>>> Jens
> >>>>> 
> >>>> 
> >>>> --
> >>>> email: [email protected]   https://eknet.org  pgp: 481161A0
> >> 
> > 
> > -- 
> > email: [email protected]   https://eknet.org  pgp: 481161A0
> 

-- 
email: [email protected]   https://eknet.org  pgp: 481161A0

Reply via email to