I did what You told me to do and here's what I've got:
[test] Error creating net.uniopt.jdo.example1.ProductGroup, SQL : INSERT INTO "PRODUCT_GROUP" ("ID","NAME") VALUES ("PRODUCT_GROUP_SEQ"."nextval",?)
net.uniopt.jdo.example1.ProductGroup:-1 becomes transient.
org.exolab.castor.jdo.PersistenceException: Nested error: com.sap.dbtech.jdbc.exceptions.DatabaseException: [-5004] (at 52): Missing constant
com.sap.dbtech.jdbc.exceptions.DatabaseException: [-5004] (at 52): Missing constant
As you can see in the first line there's obviously a failure in the SQL generated by Castor. So I guess it's a bug in Castor or in the SAP DB driver resp.
Do you agree?
Regards,
Michael Simons
At 12:59 03.07.2003 +0400, you wrote:
Hello Michael,
Unfortunally i haven't any expertise working with SAP DB and can't give you some realy tips. But, just one of workaround - is trace SQL posted by Castor to the DB and look at this. Then try run it directly on DB SQL manager.
How to set up Castor Logging you can see at:
http://www.brainopolis.com/castorwiki/Wiki.jsp?page=IntegratingLogging
Then you get SQL from Castor try to run it directly on SAP DB, if you get any errors, then misstake in SEQUECNCE on DB side, if not on is Castor problems, maybe within mapping or classes structure.
Good luck!
- -----Original Message-----
- From: michael simons [mailto:[EMAIL PROTECTED]]
- Sent: Wednesday, July 02, 2003 9:40 PM
- To: [EMAIL PROTECTED]
- Subject: Re: [castor-dev] Sequence and SAP-DB
- Hi Alexey, et al,
- still doesn't work. Now I get the following exception
- org.exolab.castor.jdo.PersistenceException: Nested error: com.sap.dbtech.jdbc.exceptions.DatabaseException: [-5004] (at 52): Missing constant
- com.sap.dbtech.jdbc.exceptions.DatabaseException: [-5004] (at 52): Missing constant
- I've been testing with a simpler example this time, so mapping follows:
- <mapping>
- <key-generator name="SEQUENCE" alias="PRODUCT_GROUP_SEQ">
- <param name="sequence" value="PRODUCT_GROUP_SEQ"/>
- </key-generator>
- <!--
- ** Mapping for ProductGroup
- -->
- <class name="net.uniopt.jdo.example1.ProductGroup" identity="id" key-generator="PRODUCT_GROUP_SEQ">
- ...
- what am I doing wrong?
- Regards,
- michael
- At 16:18 02.07.2003 +0400, you wrote:
- Hello!
- It becose you set parameter "trigger" to true
- http://www.castor.org/key-generator.html#SEQUENCE-key-generator
- you may set the "trigger" parameter to "true". This will prevent the "Sequence_name".nexval from being pulled twice (first time in the insert statement (see above), then in the trigger). Also usefull in combination with the "returning" parameter set to "true" for Oracle (in this case you may not specify the sequence name).
- So, if you set trigger to true, you must set up insert trigger for your tables and generate ID in this trigger before insert. Castor will not try generate any keys in this case.
- Good luck!
- -----Original Message-----
- From: michael simons [mailto:[EMAIL PROTECTED]]
- Sent: Wednesday, July 02, 2003 4:11 PM
- To: [EMAIL PROTECTED]
- Subject: [castor-dev] Sequence and SAP-DB
- Hello,
- Does anybody know whether key generating by sequence works w/ SAP-DB?
- I tried by the following in my mapping file but when running the program I always get a NotNull exception for the id field (i.e. the primary key "id" was not set)
- <begin mapping.xml>
- ...
- <key-generator
name="SEQUENCE">- <param
name="sequence" value="stromboli"/>- <param
name="trigger" value="true"/>- </key-generator>
- ...
- <class
name="net.uniopt.biz.sys.Language" extends="net.uniopt.data.DataObject" identity="id" key-generator="SEQUENCE">- ...
- <end mapping.xml>
- Regards,
- michael
