Hi Dirk,
your key-generator attribute should be part of the class element and not part of the
field element. Example:
<class name="ShippingLine" identity="id" key-generator="identity">
...
Best regards
Manfred
-----Ursprüngliche Nachricht-----
Von: Dirk Kunert [mailto:dirk.kunert@;gmx.net]
Gesendet: Do 17.10.2002 16:43
An: [EMAIL PROTECTED]
Cc:
Betreff: [castor-dev] problems with castor jdo and ms sql server identity flag
i am having a problem with castor jdo and ms sql server:
i create a table
shipping_line(int id, name varchar(80))
and set the identity flag of "id" to "yes". i also create a java class:
pubic class ShippingLine {
private int id;
private String name;
public ShippingLine() {}
public ShippingLine(String name) { this.name = name; }
public setId(int id) { this.id = id; }
public setName(String name) { this.name = name; }
public int getId() { return id; }
public String getName() { return name; }
}
and a config file
<database name="jdo" engine="sql-server">
<driver class-name="weblogic.jdbc.mssqlserver4.Driver"
url="jdbc:weblogic:mssqlserver:localhost:1433">
<param name="user" value="aUser"/>
<param name="password" value="aPassword"/>
</driver>
<mapping>
<class name="ShippingLine" identity="id">
<map-to table="shipping_line"/>
<field name="id" type="integer"
key-generator="identity">
<sql name="id" type="integer"/>
</field>
<field name="name" type="string"
required="true">
<sql name="name" type="string"/>
</field>
</class>
</mapping>
<key-generator name="IDENTITY" alias="identity"/>
</database>
when i instanciate the shipping line whith
ShippingLine shippingLine = new ShippingLine("myLine");
and perform
database.create(shippingLine)
within an transaction i get the error
"java.SQL.Exception: Cannot insert explicit value for identity column in
table 'shippin_line' when IDENTITY_INSERT is set OFF. ..."
how can correct this error?
thank you
--
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev