You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ddlutils-user@db.apache.org by Rijk van Haaften <r....@gmail.com> on 2008/02/20 16:17:50 UTC

PlatformImplBase.store() proposal

Hi all,

Noticing that PlatformImplBase.store() was not implemented, I'd
propose and discuss an implementation for it (attached).

To be discussed:
1) I think I need the Database model for the getDynaClassFor call, but
in order to acommodate that I changed
protected boolean exists(Connection connection, DynaBean dynaBean)
to
protected boolean exists(Connection connection, Database model,
DynaBean dynaBean)
What were the thoughts behind the original method signature choice?

2) I'm not sure about exception that should be thrown if exists fails,
currently:
catch (SQLException ex)
{
    throw new DatabaseOperationException("Error while reading from the
database", ex);
}

Rijk J.C. van Haaften

Re: PlatformImplBase.store() proposal

Posted by Thomas Dudziak <to...@gmail.com>.
On Wed, Feb 20, 2008 at 11:36 PM, Rijk van Haaften
<r....@gmail.com> wrote:
> > Look at the fetch method implementation, it does similar things and
>  >  you can probably use it as a blueprint for the exists one.
>  I did and think the implementation should be:
>  Statement statement = null;
>  ResultSet resultSet = null;
>  boolean exists = false;
>  try
>  {
>     statement = connection.createStatement();
>     resultSet = statement.executeQuery(sql.toString());
>     exists = resultSet.next();
>     resultSet.close();
>
> }
>  catch (SQLException ex)
>  {
>     throw new DatabaseOperationException("Error while reading from the
>  database", ex);
>  }
>  finally
>  {
>     closeStatement(statement);
>  }
>  return exists;
>
>  As I have no commit rights (and as far as I know, you are currently
>  the only committer), committing is up to you.

Please create a issue in DdlUtils' JIRA and attach the code to it.

thanks,
Tom

Re: PlatformImplBase.store() proposal

Posted by Rijk van Haaften <r....@gmail.com>.
> Look at the fetch method implementation, it does similar things and
>  you can probably use it as a blueprint for the exists one.
I did and think the implementation should be:
Statement statement = null;
ResultSet resultSet = null;
boolean exists = false;
try
{
    statement = connection.createStatement();
    resultSet = statement.executeQuery(sql.toString());
    exists = resultSet.next();
    resultSet.close();
}
catch (SQLException ex)
{
    throw new DatabaseOperationException("Error while reading from the
database", ex);
}
finally
{
    closeStatement(statement);
}
return exists;

As I have no commit rights (and as far as I know, you are currently
the only committer), committing is up to you.

Re: PlatformImplBase.store() proposal

Posted by Thomas Dudziak <to...@gmail.com>.
Hi Rijk,

Mhmm, yes, totally forgot about that one :-)

On Feb 20, 2008 7:17 AM, Rijk van Haaften <r....@gmail.com> wrote:

> Noticing that PlatformImplBase.store() was not implemented, I'd
> propose and discuss an implementation for it (attached).
>
> To be discussed:
> 1) I think I need the Database model for the getDynaClassFor call, but
> in order to acommodate that I changed
> protected boolean exists(Connection connection, DynaBean dynaBean)
> to
> protected boolean exists(Connection connection, Database model,
> DynaBean dynaBean)
> What were the thoughts behind the original method signature choice?

Yes, you're right, the exists method would need the database model, as well.

> 2) I'm not sure about exception that should be thrown if exists fails,
> currently:
> catch (SQLException ex)
> {
>     throw new DatabaseOperationException("Error while reading from the
> database", ex);
> }

Look at the fetch method implementation, it does similar things and
you can probably use it as a blueprint for the exists one.

Tom