Hi Bin, Thanks for taking time to reply.
My question is whether we should permit both a persistent field and a persistent property to have the same name. I think that the answer is no. I'm not sure if this is also your position.
In your example, referring to "${user.name}", should you get the value of the field called name, or get the result of getName()? I believe that the specification of EL requires a property, i.e. getName ().
And in JDOQL, if you have a persistent property called name, then name == "Mike" gives you the right result.
It's really up to the user whether to use persistent properties or persistent fields. Your examples can work with either properties or fields, but the results are ambiguous if you have both persistent field "name" and persistent property "name".
Craig On Mar 15, 2007, at 7:55 PM, Bin Sun wrote:
Hi! I strongly oppose to using a different field name for a property. For a webapp, we may use a JDO javabean like this: "${user.name}", and we also frequently need to do JDOQL like this: "name=='Mike'". Keeping field names the same as property names can reduce much confusion for coders. This is a basic rule for my development. How do others think? --- Erik Bengtson <[EMAIL PROTECTED]> wrote:Hi, We are implementing persistent properties, and I have some questions. Question 1: ------------------ Take this example: <class name="Person"> <field name="name"/> <property name="birth"/> </class> class Person { String name; String _birth; public Date getBirth() { return this._birth; } public void setBirth(Date birth) { this._birth = birth; } } Is it allowed to have mixed persistent fields and persistent properties in same Class or Super Classes? In JPA, this is explicitly unspecified. IMO it should not be allowed to avoid user errors (possibly overriding values or persisting twice the same information). Question 2: ------------------ Take this example: <class name="Person"> <property name="name"/> <property name="birth"/> </class> class Person { String _name; String _birth; public String getName() { return this._name; } public void setString(String name) { this._name = name; } public Date getBirth() { return this._birth; } public void setBirth(Date birth) { this._birth = birth; } } By default, _name and _birth would have persistence modifier = persistent. In this case we are using persistent properties, does the default persistence modifier for fields changes to transient? Question 3: ------------------ Take this example: <class name="Person"> <property name="name"/> <property name="birth"/> </class> class Person { String _name; String _birth; public String getName() { return this._name; } public void setString(String name) { this._name = name; } public Date getBirth() { throw new UnbornException(); } public void setBirth(Date birth) { this._birth = birth; } } If an exception is raised from the getter/setter, what should be done by the implementation? In JPA, there is an automatic rollback. Regards, Erik Bengtson______________________________________________________________________ ______________Don't pick lemons. See all the new 2007 cars at Yahoo! Autos. http://autos.yahoo.com/new_cars.html
Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:[EMAIL PROTECTED] P.S. A good JDO? O, Gasp!
smime.p7s
Description: S/MIME cryptographic signature
