db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bin Sun <sun2...@yahoo.com>
Subject Re: Persistent properties for classes
Date Fri, 16 Mar 2007 02:55:06 GMT
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 <erik@jpox.org> 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 

Mime
View raw message