Re: error committing new created object

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Jan 05 2006 - 04:49:26 EST

  • Next message: Andrus Adamchik: "Re: error committing new created object"

    On Jan 4, 2006, at 11:53 AM, Lothar Krenzien wrote:

    > Caused by: java.lang.AbstractMethodError:
    > com.microsoft.jdbc.sqlserver.SQLServerConnection.prepareStatement
    > (Ljava/lang/String;I)Ljava/sql/PreparedStatement;

    Generated keys support on MS SQLServer is very confusing as I've
    mentioned in other threads. In your case the problem is that MS
    driver does not support this feature, hence the exception.

    My suggestion is to (a) manually configure adapter on startup to
    suppress the use of JDBC API for generated keys (see the code below)
    and (b) leave PK mapped as "generated" to avoid another problem
    described here:

    http://objectstyle.org/cayenne/lists/cayenne-user/2006/01/0038.html

    Here is the code:

    DataDomain domain = Configuration.getSharedConfiguration().getDomain();
    DataMap map = domain.getEntityResolver().lookupObjEntity
    (TblImportAlert.class).getDataMap();
    DataNode node = domain.lookupDataNode(map);
    JdbcAdapter adapter = (JdbcAdapter) node.getAdapter();
    adapter.setSupportsGeneratedKeys(false);

    ... or switch to jTDS driver that supports generated keys on SQL Server:

    http://jtds.sourceforge.net/

    Andrus



    This archive was generated by hypermail 2.0.0 : Thu Jan 05 2006 - 04:49:28 EST