db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: JPOX issues
Date Wed, 15 Mar 2006 22:50:01 GMT
Hi Erik,

Sorry, I thought I had answered this but found the message in my "to  
be sent" box.

The instance returned from newInstance is transient. The application  
treats the new instance just like an instance created via the "new PC 
()" method call. An example implementation is:

Object newInstance(Class pcClass) {
   if (it's a persistent interface or abstract class) {
   ... construct your implementation based on metadata
   } else if  (PersistenceCapable.class.isAssignableFrom(pcClass) {
     return pc.getConstructor(new Class[ ]{}).newInstance(); //  
throws if abstract class or no privileges
   } else {
   throw JDOUserException...
   }
}

Craig

<spec>
The following method is used to create an instance of a persistence- 
capable interface, or of
a concrete or abstract class.
Object newInstance(Class persistenceCapable);
The parameter must be one of the following:
•an abstract class that is declared in the metadata using the class  
element, or
•an interface that is declared in the metadata using the interface  
element, or
•a concrete class that is declared in the metadata as persistence- 
capable. In this case,
the concrete class must declare a public no-args constructor.
The returned instance is transient, and is an “instanceof” the  
parameter. Applications
might use the instance via the get and set property methods and  
change its life cycle
state exactly as if it were an instance of a persistence-capable class.
In order for the newInstance method to be used, the parameter  
interface must be com-
pletely mapped. For relational implementations, the interface must be  
mapped to a table
and all persistent properties must be mapped to columns.  
Additionally, interfaces that are
the targets of all relationships from persistent propertiesþ must  
also be mapped. Otherwise,
JDOUserException is thrown by the newInstance method.
For interfaces and classes that use a SingleFieldIdentity as the  
object-id class, if the
returned instance is subsequently made persistent, the target class  
stored in the object-id
instance is the parameter of the newInstance method that created it.
</spec>
On Mar 15, 2006, at 1:59 PM, Erik Bengtson wrote:

> Hi,
>
> All issues in JPOX were solved but not the ones related to the  
> newInstance
> tests.
>
>> It's not clear to me in what state must be the instance created by  
>> this
>> method.
>
> Can someone answer this?
>
> Quoting Erik Bengtson <erik@jpox.org>:
>
>> Craig,
>>
>> It's not clear to me in what state must be the instance created by  
>> this
>> method.
>> Can you clarify?
>>
>> Thanks
>>
>> Quoting Craig L Russell <Craig.Russell@Sun.COM>:
>>
>>> Hi Erik,
>>>
>>> On Mar 14, 2006, at 1:21 PM, Erik Bengtson wrote:
>>>
>>>> Can someone with spring understanding check JDO-327 ?
>>>
>>> Your symptom is different from mine. Have you checked in all the  
>>> code
>>> that gives you the error on pm.newInstance(IDentalInsurance.class) ?
>>>
>>>>
>>>> With me
>>>> JDO-241
>>>> JDO-246 (Issue in derby, needs workaround implemented in JPOX)
>>>> JDO-337 (to be fixed tonight)
>>>>
>>>> Work not started
>>>> JDO-326 (abstract class support)
>>>
>>> Note that this is not abstract class support. The parameter is a
>>> concrete class. "All the implementation has to do" is to recognize
>>> that the parameter is PersistenceCapable, and call the  
>>> jdoNewInstance
>>> () method that's enhanced into the class.
>>>
>>> Regards,
>>>
>>> Craig
>>>>
>>>>
>>>> Quoting Craig L Russell <Craig.Russell@Sun.COM>:
>>>>
>>>>> Hi,
>>>>>
>>>>> I'm looking at JDO JIRA issues 241, 246, 326, 327, and 337, and  
>>>>> I'm
>>>>> assuming that these issues are being looked at by the JPOX folks.
>>>>>
>>>>> Please correct me if there's some TCK activity needed here.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Craig
>>>>>
>>>>> Craig Russell
>>>>> Architect, Sun Java Enterprise System http://java.sun.com/ 
>>>>> products/
>>>>> jdo
>>>>> 408 276-5638 mailto:Craig.Russell@sun.com
>>>>> P.S. A good JDO? O, Gasp!
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>> Craig Russell
>>> Architect, Sun Java Enterprise System http://java.sun.com/ 
>>> products/jdo
>>> 408 276-5638 mailto:Craig.Russell@sun.com
>>> P.S. A good JDO? O, Gasp!
>>>
>>>
>>
>>
>>
>>
>
>
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Mime
View raw message