[Objectbridge-jdo-dev] RE: default mapping rules (Brian Westrich)
Brought to you by:
thma
From: Brian W. <bw...@mc...> - 2002-05-28 10:11:14
|
Oops, noticed my last post contained non-ASCII characters which weren't very readable. Below is a cleaned up version of the original post. Also, since posting I noticed someone mentioned the need to map relationship related fields. The Forte tool does this as well. The convention it uses is: For fields that map to one instance of another class: class name starting with lower case letter (e.g. myClass) For fields that map to 0-n instances of another class: class name starting with lower case letter + "CollectionFor" + primary key property(ies) (e.g. if MyClass has a primary key field named myId, and the table mapped to MyClass has a table named MY_DETAIL_CLASS, the relationship field would be named myDetailClassCollectionForMyId) The above convention for 0-n is the 'complex cardinality' convention. One can also choose a 'simple cardinality', which leaves the "ForMyId" part off the name. -- Brian > Hi ojb developers, > > It=92s great to learn of your efforts to write an open-source JDO > product! Having used the free JDO stuff bundled with Forte for > Java 3.0, I=92m smitten by the benefits of JDO, but since JDO is > discontinued in the next release of Forte (now called Sun ONE), > I=92m looking for a replacement. I can=92t help out much with ojb > right now, as I=92m knee deep in a couple projects until at least > mid-Summer. So if you don=92t mind I=92ll mostly just keep reading > the dev mailing list. > > Having said this... I do have one possible small (code) > contribution. As you consider default mappings, you might > consider using the conventions used by the schema reverse > engineering tool bundled with Forte for Java (which generates > classes from an existing schema). This converts database schema > using underscores for word separators (e.g. MY_TABLE, > MY_COLUMN) into Java-like mixed case names (e.g. MyClass, > myProperty). This convention allows one to quickly set up JDO > objects to talk with an existing database schema without any > underscores in Java class names. If ojb used this convention, > ojb users with existing databases could use the Forte tool to > generate initial versions of their classes. I know such a > simple mapping (table to class, column to property) is > simplistic, etc., but it sure is a great way to get started. > Another option, if you=92re not comfortable with this particular > convention, is to add an extension tag to the *.jdo file > (perhaps at the package and/or class level) indicating that > this convention was in use. If you=92d like, I=92d be delighted to > contribute code and JUnit tests to the project that do these > conversions. > > I look forward to seeing your thoughts on the list related to > this idea on default mappings. > > Keep the faith! > > -- Brian > > Brian Westrich > McWest Corp. > bw...@mc... > 612-508-1827 > |