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