This one time, at band camp, Christian Dellwo said:
CD>I've got the following problem:
CD>I want to use the MAX key generator for an object that extends another
CD>object. But it doesn't work...
CD>Here is my mapping:
CD>
CD><!----- BEGIN --->
CD><mapping>
CD><class identity="id_person.wert" name="jvfa.modules.kunden.Person"
CD>key-generator="MAX">
CD><map-to table="person"/>
CD> <field name="id_person.wert" type="integer">
CD> <sql name="id_person" type="integer"/>
CD> <bind-xml name="id_person"/>
CD> </field>
CD> <field name="name.wert" type="string">
CD> <sql name="name" type="varchar"/>
CD> <bind-xml name="name"/>
CD> </field>
CD></class>
CD>
CD><class name="jvfa.modules.kunden.Kunde" extends="jvfa.modules.kunden.Person"
CD>identity="id_kunde.wert" key-generator="MAX">
CD> <map-to table="kunde"/>
CD> <field name="id_kunde.wert" type="integer">
CD> <sql name="id_kunde" type="integer"/>
CD> <bind-xml name="id_kunde"/>
CD> </field>
CD> <field name="berufsstand.wert" type="string">
CD> <sql name="berufsstand" type="varchar"/>
CD> <bind-xml name="berufsstand"/>
CD> </field>
CD></class>
CD></mapping>
CD><!----- END --->
CD>
CD>
CD>As you can see, Kunde extends Person.
CD>When I store a Person object with create() in the Database, it works.
CD>He is inserting a new record with a new ID for each person I insert.
CD>So far, so good.
CD>
CD>But I want to insert a Kunde object. And here he doesn't use the
CD>key-generator and I don't know why. I've debugged it, by placing breakpoints
CD>in
CD>MaxKeyGenerator.generateKey() and in SQLEngine.create(), and I could see,
CD>that he
CD>first wants to insert the Person (there he uses again the key-generator) and
CD>then he tries to insert the Kunde object (and here no key-generator is
CD>used).
CD>Then I get a Nested error: java.sql.SQLException: ERROR: Cannot insert a
CD>duplicate key into unique index kunde_pkey
CD>
CD>If I don't use a key generator and set the values of the identity fields by
CD>myself, everything works, I can insert a Kunde object and he is inserting
CD>the
CD>correct values in both tables, kunde and person.
CD>
CD>What must I do, that he uses the key generator for the Kunde object too?
CD>Is something wrong with my mapping or is the error somewhere else?
Christian,
Have you tried specifying the key generator only on the Person
object and not on the Kunde object?
Bruce
--
perl -e 'print unpack("u30","<0G)[EMAIL PROTECTED]&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'
The Castor Project
http://www.castor.org/
Apache Geronimo
http://incubator.apache.org/projects/geronimo.html
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev