db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Bengtson <e...@jpox.org>
Subject Persistent properties for classes
Date Wed, 14 Mar 2007 09:47:55 GMT
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

Mime
View raw message