In your mapping you have selected the database engine as "generic". Identity key generation strategies are only supported by certain databases like MS SQL Server and MySQL.
i.e change your current database config: <database engine="generic" name="testingwbc"> to: <database engine="THE TYPE OF DB YOU ARE USING" name="testingwbc"> The supported engines are discussed here: http://www.castor.org/database-conf.html Ensure that your database actually supports Identity generation, otherwise use HIGH LOW or MAX etc. There is a discussion of key generation on the website here. http://www.castor.org/key-generator.html Hope this helps Patrick -----Original Message----- From: Ng Keng Yap [mailto:[EMAIL PROTECTED] Sent: Thu 9/30/2004 1:46 PM To: [EMAIL PROTECTED] Subject: Re: [castor-user] JDO error Dear Bruce, Thanks for the message. I can connect to the database now, but I ended up with another problem. I actually feel tensed and depressed using Castor due to the limited documentation I can get. I don't use XML Mapping file and I assume that Castor will use the reflection API to cater the generated codes (Java Object). The Project.java is one of the generated file which is similar to the Apache Maven Project. I try to load the Project.java object to th MySQL. I failed and ended up with he following error: Sep 30, 2004 8:19:40 PM org.exolab.castor.jdo.engine.BaseFactory getPersistence SEVERE: A fatal exception occurred: org.exolab.castor.mapping MappingException: The key generator org.exolab.castor.jdo.drivers IdentityKeyGenerator is not compatible with the persistence factory generic. org.exolab.castor.jdo.PersistenceException: non persistence capable: com smml.castor.bean.Project at org.exolab.castor.persist.ClassMolder.create(ClassMolder.java:846) at org.exolab.castor.persist.LockEngine.create(LockEngine.java:489) at org.exolab.castor.persist.TransactionContext.create(TransactionContext java:883) at org.exolab.castor.jdo.engine.DatabaseImpl.create(DatabaseImpl.java:363) at com.smml.toolkit.MyDataBindingManager.<init>(MyDataBindingManager java:41) at com.smml.toolkit.MyDataBindingManager.main(MyDataBindingManager.java:53) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl java:39) at sun.reflect.DelegatingMethodAccessorImpl invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78) Database Configuration: <?xml version="1.0" encoding="UTF-8"?> <database engine="generic" name="testingwbc"> <driver class-name="com.mysql.jdbc.Driver" url= jdbc:mysql://localhost:3306/testingwbc"> <param name="username" value="root"/> <param name="password" value=""/> </driver> <mapping href="File:/C:/database.mapping"/> </database> JDO Mapping (database.mapping): <mapping> <class name="com.smml.castor.bean.Project" identity="id" key-generator= IDENTITY"> <map-to table="project" /> <field name="id" type="integer"> <sql name="id" type="integer" /> </field> <field name="name" type="string"> <sql name="name" type="char" /> </field> <field name="version" type="string"> <sql name="price" type="char" /> </field> </class> </mapping> Main Class: package com.smml.toolkit; import org.exolab.castor.jdo.JDO; import org.exolab.castor.xml.Unmarshaller; import java.io.File; import java.io.FileReader; import com.smml.castor.JDOSession.Database; import com.smml.castor.bean.Project; /** * User: Ng Keng Yap * Date: Sep 23, 2004 * Time: 9:33:52 AM */ public class MyDataBindingManager { File databaseConf = new File(MyToolkit.getIniProperty("smml.home") + File.separator + "conf" + File.separator + "database.conf"); File databaseXsd = new File(MyToolkit.getIniProperty("smml.home") + File separator + "conf" + File.separator + "database.xsd"); public MyDataBindingManager() { try { Database database = new Database(); FileReader fr = new FileReader(databaseConf); database = (Database)Unmarshaller.unmarshal(database.getClass() fr ) ; fr.close(); JDO jdo; org.exolab.castor.jdo.Database db; // Define the JDO object jdo = new JDO(); jdo.setDatabaseName(database.getName()); jdo.setConfiguration(databaseConf.getAbsolutePath()); jdo.setClassLoader(getClass().getClassLoader()); // Obtain a new database db = jdo.getDatabase(); // Begin a transaction db.begin(); // Do something Project project = new Project(); db.create(project); // Commit the transaction, close database db.commit(); db.close(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { new MyDataBindingManager(); } } Java Object: /* * This class was automatically generated with * <a href="http://www.castor.org">Castor 0.9.5.3</a>, using an XML * Schema. * $Id$ */ package com.smml.castor.bean; //---------------------------------/ //- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** * Class Project. * * @version $Revision$ $Date$ */ public class Project implements java.io.Serializable { //--------------------------/ //- Class/Member Variables -/ //--------------------------/ /** * Field _version */ private java.lang.String _version; /** * Field _name */ private java.lang.String _name; /** * Field _id */ private java.lang.Object _id; /** * Field _currentVersion */ private com.smml.castor.bean.CurrentVersion _currentVersion; /** * Field _organization */ private com.smml.castor.bean.Organization _organization; /** * Field _inceptionYear */ private int _inceptionYear; /** * keeps track of state for field: _inceptionYear */ private boolean _has_inceptionYear; /** * Field _package */ private com.smml.castor.bean.Package _package; /** * Field _shortDescription */ private com.smml.castor.bean.ShortDescription _shortDescription; /** * Field _description */ private java.lang.String _description; /** * Field _url */ private java.lang.String _url; /** * Field _cvsWebUrl */ private java.lang.String _cvsWebUrl; /** * Field _issueTrackingUrl */ private java.lang.String _issueTrackingUrl; /** * Field _siteAddress */ private com.smml.castor.bean.SiteAddress _siteAddress; /** * Field _siteDirectory */ private com.smml.castor.bean.SiteDirectory _siteDirectory; /** * Field _distributionDirectory */ private com.smml.castor.bean.DistributionDirectory _distributionDirectory; /** * Field _cvsRoot */ private com.smml.castor.bean.CvsRoot _cvsRoot; /** * Field _cvsModule */ private com.smml.castor.bean.CvsModule _cvsModule; /** * Field _distributions */ private com.smml.castor.bean.Distributions _distributions; /** * Field _branches */ private com.smml.castor.bean.Branches _branches; /** * Field _mailingLists */ private com.smml.castor.bean.MailingLists _mailingLists; /** * Field _developers */ private com.smml.castor.bean.Developers _developers; /** * Field _dependencies */ private com.smml.castor.bean.Dependencies _dependencies; //----------------/ //- Constructors -/ //----------------/ public Project() { super(); } //-- com.smml.castor.bean.Project() //-----------/ //- Methods -/ //-----------/ /** * Method deleteInceptionYear */ public void deleteInceptionYear() { this._has_inceptionYear = false; } //-- void deleteInceptionYear() /** * Returns the value of field 'branches'. * * @return the value of field 'branches'. */ public com.smml.castor.bean.Branches getBranches() { return this._branches; } //-- com.smml.castor.bean.Branches getBranches() /** * Returns the value of field 'currentVersion'. * * @return the value of field 'currentVersion'. */ public com.smml.castor.bean.CurrentVersion getCurrentVersion() { return this._currentVersion; } //-- com.smml.castor.bean.CurrentVersion getCurrentVersion() /** * Returns the value of field 'cvsModule'. * * @return the value of field 'cvsModule'. */ public com.smml.castor.bean.CvsModule getCvsModule() { return this._cvsModule; } //-- com.smml.castor.bean.CvsModule getCvsModule() /** * Returns the value of field 'cvsRoot'. * * @return the value of field 'cvsRoot'. */ public com.smml.castor.bean.CvsRoot getCvsRoot() { return this._cvsRoot; } //-- com.smml.castor.bean.CvsRoot getCvsRoot() /** * Returns the value of field 'cvsWebUrl'. * * @return the value of field 'cvsWebUrl'. */ public java.lang.String getCvsWebUrl() { return this._cvsWebUrl; } //-- java.lang.String getCvsWebUrl() /** * Returns the value of field 'dependencies'. * * @return the value of field 'dependencies'. */ public com.smml.castor.bean.Dependencies getDependencies() { return this._dependencies; } //-- com.smml.castor.bean.Dependencies getDependencies() /** * Returns the value of field 'description'. * * @return the value of field 'description'. */ public java.lang.String getDescription() { return this._description; } //-- java.lang.String getDescription() /** * Returns the value of field 'developers'. * * @return the value of field 'developers'. */ public com.smml.castor.bean.Developers getDevelopers() { return this._developers; } //-- com.smml.castor.bean.Developers getDevelopers() /** * Returns the value of field 'distributionDirectory'. * * @return the value of field 'distributionDirectory'. */ public com.smml.castor.bean.DistributionDirectory getDistributionDirectory() { return this._distributionDirectory; } //-- com.smml.castor.bean.DistributionDirectory getDistributionDirectory() /** * Returns the value of field 'distributions'. * * @return the value of field 'distributions'. */ public com.smml.castor.bean.Distributions getDistributions() { return this._distributions; } //-- com.smml.castor.bean.Distributions getDistributions() /** * Returns the value of field 'id'. * * @return the value of field 'id'. */ public java.lang.Object getId() { return this._id; } //-- java.lang.Object getId() /** * Returns the value of field 'inceptionYear'. * * @return the value of field 'inceptionYear'. */ public int getInceptionYear() { return this._inceptionYear; } //-- int getInceptionYear() /** * Returns the value of field 'issueTrackingUrl'. * * @return the value of field 'issueTrackingUrl'. */ public java.lang.String getIssueTrackingUrl() { return this._issueTrackingUrl; } //-- java.lang.String getIssueTrackingUrl() /** * Returns the value of field 'mailingLists'. * * @return the value of field 'mailingLists'. */ public com.smml.castor.bean.MailingLists getMailingLists() { return this._mailingLists; } //-- com.smml.castor.bean.MailingLists getMailingLists() /** * Returns the value of field 'name'. * * @return the value of field 'name'. */ public java.lang.String getName() { return this._name; } //-- java.lang.String getName() /** * Returns the value of field 'organization'. * * @return the value of field 'organization'. */ public com.smml.castor.bean.Organization getOrganization() { return this._organization; } //-- com.smml.castor.bean.Organization getOrganization() /** * Returns the value of field 'package'. * * @return the value of field 'package'. */ public com.smml.castor.bean.Package getPackage() { return this._package; } //-- com.smml.castor.bean.Package getPackage() /** * Returns the value of field 'shortDescription'. * * @return the value of field 'shortDescription'. */ public com.smml.castor.bean.ShortDescription getShortDescription() { return this._shortDescription; } //-- com.smml.castor.bean.ShortDescription getShortDescription() /** * Returns the value of field 'siteAddress'. * * @return the value of field 'siteAddress'. */ public com.smml.castor.bean.SiteAddress getSiteAddress() { return this._siteAddress; } //-- com.smml.castor.bean.SiteAddress getSiteAddress() /** * Returns the value of field 'siteDirectory'. * * @return the value of field 'siteDirectory'. */ public com.smml.castor.bean.SiteDirectory getSiteDirectory() { return this._siteDirectory; } //-- com.smml.castor.bean.SiteDirectory getSiteDirectory() /** * Returns the value of field 'url'. * * @return the value of field 'url'. */ public java.lang.String getUrl() { return this._url; } //-- java.lang.String getUrl() /** * Returns the value of field 'version'. * * @return the value of field 'version'. */ public java.lang.String getVersion() { return this._version; } //-- java.lang.String getVersion() /** * Method hasInceptionYear */ public boolean hasInceptionYear() { return this._has_inceptionYear; } //-- boolean hasInceptionYear() /** * Method isValid */ public boolean isValid() { try { validate(); } catch (org.exolab.castor.xml.ValidationException vex) { return false; } return true; } //-- boolean isValid() /** * Method marshal * * @param out */ public void marshal(java.io.Writer out) throws org.exolab.castor.xml.MarshalException, org.exolab.castor xml.ValidationException { Marshaller.marshal(this, out); } //-- void marshal(java.io.Writer) /** * Method marshal * * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) throws java.io.IOException, org.exolab.castor.xml MarshalException, org.exolab.castor.xml.ValidationException { Marshaller.marshal(this, handler); } //-- void marshal(org.xml.sax.ContentHandler) /** * Sets the value of field 'branches'. * * @param branches the value of field 'branches'. */ public void setBranches(com.smml.castor.bean.Branches branches) { this._branches = branches; } //-- void setBranches(com.smml.castor.bean.Branches) /** * Sets the value of field 'currentVersion'. * * @param currentVersion the value of field 'currentVersion'. */ public void setCurrentVersion(com.smml.castor.bean.CurrentVersion currentVersion) { this._currentVersion = currentVersion; } //-- void setCurrentVersion(com.smml.castor.bean.CurrentVersion) /** * Sets the value of field 'cvsModule'. * * @param cvsModule the value of field 'cvsModule'. */ public void setCvsModule(com.smml.castor.bean.CvsModule cvsModule) { this._cvsModule = cvsModule; } //-- void setCvsModule(com.smml.castor.bean.CvsModule) /** * Sets the value of field 'cvsRoot'. * * @param cvsRoot the value of field 'cvsRoot'. */ public void setCvsRoot(com.smml.castor.bean.CvsRoot cvsRoot) { this._cvsRoot = cvsRoot; } //-- void setCvsRoot(com.smml.castor.bean.CvsRoot) /** * Sets the value of field 'cvsWebUrl'. * * @param cvsWebUrl the value of field 'cvsWebUrl'. */ public void setCvsWebUrl(java.lang.String cvsWebUrl) { this._cvsWebUrl = cvsWebUrl; } //-- void setCvsWebUrl(java.lang.String) /** * Sets the value of field 'dependencies'. * * @param dependencies the value of field 'dependencies'. */ public void setDependencies(com.smml.castor.bean.Dependencies dependencies) { this._dependencies = dependencies; } //-- void setDependencies(com.smml.castor.bean.Dependencies) /** * Sets the value of field 'description'. * * @param description the value of field 'description'. */ public void setDescription(java.lang.String description) { this._description = description; } //-- void setDescription(java.lang.String) /** * Sets the value of field 'developers'. * * @param developers the value of field 'developers'. */ public void setDevelopers(com.smml.castor.bean.Developers developers) { this._developers = developers; } //-- void setDevelopers(com.smml.castor.bean.Developers) /** * Sets the value of field 'distributionDirectory'. * * @param distributionDirectory the value of field * 'distributionDirectory'. */ public void setDistributionDirectory(com.smml.castor.bean DistributionDirectory distributionDirectory) { this._distributionDirectory = distributionDirectory; } //-- void setDistributionDirectory(com.smml.castor.bean DistributionDirectory) /** * Sets the value of field 'distributions'. * * @param distributions the value of field 'distributions'. */ public void setDistributions(com.smml.castor.bean.Distributions distributions) { this._distributions = distributions; } //-- void setDistributions(com.smml.castor.bean.Distributions) /** * Sets the value of field 'id'. * * @param id the value of field 'id'. */ public void setId(java.lang.Object id) { this._id = id; } //-- void setId(java.lang.Object) /** * Sets the value of field 'inceptionYear'. * * @param inceptionYear the value of field 'inceptionYear'. */ public void setInceptionYear(int inceptionYear) { this._inceptionYear = inceptionYear; this._has_inceptionYear = true; } //-- void setInceptionYear(int) /** * Sets the value of field 'issueTrackingUrl'. * * @param issueTrackingUrl the value of field 'issueTrackingUrl' */ public void setIssueTrackingUrl(java.lang.String issueTrackingUrl) { this._issueTrackingUrl = issueTrackingUrl; } //-- void setIssueTrackingUrl(java.lang.String) /** * Sets the value of field 'mailingLists'. * * @param mailingLists the value of field 'mailingLists'. */ public void setMailingLists(com.smml.castor.bean.MailingLists mailingLists) { this._mailingLists = mailingLists; } //-- void setMailingLists(com.smml.castor.bean.MailingLists) /** * Sets the value of field 'name'. * * @param name the value of field 'name'. */ public void setName(java.lang.String name) { this._name = name; } //-- void setName(java.lang.String) /** * Sets the value of field 'organization'. * * @param organization the value of field 'organization'. */ public void setOrganization(com.smml.castor.bean.Organization organization) { this._organization = organization; } //-- void setOrganization(com.smml.castor.bean.Organization) /** * Sets the value of field 'package'. * * @param _package the value of field 'package'. */ public void setPackage(com.smml.castor.bean.Package _package) { this._package = _package; } //-- void setPackage(com.smml.castor.bean.Package) /** * Sets the value of field 'shortDescription'. * * @param shortDescription the value of field 'shortDescription' */ public void setShortDescription(com.smml.castor.bean.ShortDescription shortDescription) { this._shortDescription = shortDescription; } //-- void setShortDescription(com.smml.castor.bean.ShortDescription) /** * Sets the value of field 'siteAddress'. * * @param siteAddress the value of field 'siteAddress'. */ public void setSiteAddress(com.smml.castor.bean.SiteAddress siteAddress) { this._siteAddress = siteAddress; } //-- void setSiteAddress(com.smml.castor.bean.SiteAddress) /** * Sets the value of field 'siteDirectory'. * * @param siteDirectory the value of field 'siteDirectory'. */ public void setSiteDirectory(com.smml.castor.bean.SiteDirectory siteDirectory) { this._siteDirectory = siteDirectory; } //-- void setSiteDirectory(com.smml.castor.bean.SiteDirectory) /** * Sets the value of field 'url'. * * @param url the value of field 'url'. */ public void setUrl(java.lang.String url) { this._url = url; } //-- void setUrl(java.lang.String) /** * Sets the value of field 'version'. * * @param version the value of field 'version'. */ public void setVersion(java.lang.String version) { this._version = version; } //-- void setVersion(java.lang.String) /** * Method unmarshal * * @param reader */ public static java.lang.Object unmarshal(java.io.Reader reader) throws org.exolab.castor.xml.MarshalException, org.exolab.castor xml.ValidationException { return (com.smml.castor.bean.Project) Unmarshaller.unmarshal(com smml.castor.bean.Project.class, reader); } //-- java.lang.Object unmarshal(java.io.Reader) /** * Method validate */ public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor xml.Validator(); validator.validate(this); } //-- void validate() } Thanks for you guidance. Cheers, NG KENG YAP E-mail: [EMAIL PROTECTED] Mobile: (+60) 016-394 8998 Yahoo! Messenger: ngkengyap MSN Messenger: [EMAIL PROTECTED] -------Original Message------- From: [EMAIL PROTECTED] Date: 30 September 2004 19:31:43 To: [EMAIL PROTECTED] Subject: Re: [castor-user] JDO error Ng Keng Yap wrote: > I have the following error at the code: > > Database database = JDO.getDatabase(); > > The error message is too abstract, may anybody here tell me what is wrong. . > > org.xml.sax.SAXException: unable to find FieldDescriptor for 'head' in > ClassDescriptor of mapping Without more information this is impossible to debug because I have no idea what 'head' is. Please post the jdo-conf descriptor (used to known as the database descriptor) and more of the relevant client code. 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-user
<<winmail.dat>>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
