Hi Erik,

We should be able to discuss this at Friday's conference call.

On Mar 14, 2007, at 2:47 AM, Erik Bengtson 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.

Well, not really. From 2.1.1, .A single access type (field or property access) applies to an entity hierarchy.


IMO it should not be allowed to avoid user errors (possibly overriding values or
persisting twice the same information).

But I don't see the issue with allowing implicit field persistence (since JDO 1.0) or explicit property persistence.


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?

Yes. Field names must not be the same as property names. If a property is explicitly declared to be persistent, the corresponding field must not be persistent. There are rules for determining whether fields are persistent; see 18.15 for default persistence-modifier for fields. There is no such treatment for properties.

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.

I guess this is not specified in JDO. I'd like to see this generate a StupidUserException but not set the RollbackRequired flag. Not every exception should cause a rollback.

Craig

Regards,

Erik Bengtson

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!

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to