Hello,
I've got the following problem:
I want to use the MAX key generator for an object that extends another
object. But it doesn't work...
Here is my mapping:
<!----- BEGIN --->
<mapping>
<class identity="id_person.wert" name="jvfa.modules.kunden.Person"
key-generator="MAX">
<map-to table="person"/>
<field name="id_person.wert" type="integer">
<sql name="id_person" type="integer"/>
<bind-xml name="id_person"/>
</field>
<field name="name.wert" type="string">
<sql name="name" type="varchar"/>
<bind-xml name="name"/>
</field>
</class>
<class name="jvfa.modules.kunden.Kunde" extends="jvfa.modules.kunden.Person"
identity="id_kunde.wert" key-generator="MAX">
<map-to table="kunde"/>
<field name="id_kunde.wert" type="integer">
<sql name="id_kunde" type="integer"/>
<bind-xml name="id_kunde"/>
</field>
<field name="berufsstand.wert" type="string">
<sql name="berufsstand" type="varchar"/>
<bind-xml name="berufsstand"/>
</field>
</class>
</mapping>
<!----- END --->
As you can see, Kunde extends Person.
When I store a Person object with create() in the Database, it works.
He is inserting a new record with a new ID for each person I insert.
So far, so good.
But I want to insert a Kunde object. And here he doesn't use the
key-generator and I don't know why. I've debugged it, by placing breakpoints
in
MaxKeyGenerator.generateKey() and in SQLEngine.create(), and I could see,
that he
first wants to insert the Person (there he uses again the key-generator) and
then he tries to insert the Kunde object (and here no key-generator is
used).
Then I get a Nested error: java.sql.SQLException: ERROR: Cannot insert a
duplicate key into unique index kunde_pkey
If I don't use a key generator and set the values of the identity fields by
myself, everything works, I can insert a Kunde object and he is inserting
the
correct values in both tables, kunde and person.
What must I do, that he uses the key generator for the Kunde object too?
Is something wrong with my mapping or is the error somewhere else?
Regards,
Christian Dellwo
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev