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: TCK completeness interface
Date Thu, 06 Apr 2006 01:05:26 GMT
Hi Erik,

On Apr 5, 2006, at 5:44 PM, Erik Bengtson wrote:

> More specific:
>
> CompletenessPCClassTest works great because you have classes with  
> constructors.
> When you invoke spring it instantiates the classes by calling the  
> constructors
> and passing the arguments from the XML file
>
> For CompletenessInterfaceTest you use the same "beans", but in this  
> case the
> implementation does not have constructors with arguments because the
> implementation was generated from interfaces by JPOX.

Right, the implementation needs only a no-args constructor. The  
factory method is not in the generated impl class but in the instance  
of CompanyFactoryPMInterface which extends  
CompanyFactoryAbstractInterface with the factory method:

     public IFullTimeEmployee newFullTimeEmployee(long personid,  
String first, String last, String middle, java.util.Date born,  
java.util.Date hired, double sal) {
         IFullTimeEmployee result = newFullTimeEmployee();
         if (debug) logger.debug("newFullTimeEmployee returned" +  
result);
         result.setPersonid(personid);
         result.setFirstname(first);
         result.setLastname(last);
         result.setMiddlename(middle);
         result.setBirthdate(born);
         result.setHiredate(hired);
         result.setSalary(sal);
         return result;
     }

The class CompanyFactoryPMInterface implements the abstract method:
     IFullTimeEmployee  newFullTimeEmployee() {
         return (IFullTimeEmployee)pm.newInstance 
(IFullTimeEmployee.class);
     }

Remember that the interface impl returns a transient instance. It's  
only made persistent later. I think this is probably your problem.  
The JDO impl doesn't get to persist the instance until all the fields  
are populated by the makePersistent call in CompletenessTest.

Craig
>
> Is it clear?
>
>     <bean id="emp2" factory-bean="companyFactory"
> factory-method="newFullTimeEmployee">
>         <constructor-arg index="0"
> type="long"><value>2</value></constructor-arg>
>         <constructor-arg index="1"
> type="java.lang.String"><value>emp2First</value></constructor-arg>
>         <constructor-arg index="2"
> type="java.lang.String"><value>emp2Last</value></constructor-arg>
>         <constructor-arg index="3"
> type="java.lang.String"><value>emp2Middle</value></constructor-arg>
>         <constructor-arg index="4"
> type="java.util.Date"><value>22/Dec/1975</value></constructor-arg>
>         <constructor-arg index="5"
> type="org.apache.jdo.tck.pc.company.IAddress"><ref
> local="addr2"/></constructor-arg>
>         <constructor-arg index="6"
> type="java.util.Date"><value>1/Jul/2003</value></constructor-arg>
>         <constructor-arg index="7"
> type="double"><value>10000</value></constructor-arg>
>         <property name="weeklyhours"><value>40</value></property>
>         <property name="medicalInsurance"><ref bean="medicalIns2"/ 
> ></property>
>
>
> Quoting Craig L Russell <Craig.Russell@Sun.COM>:
>
>> Hi Erik,
>>
>> All of the fields that need to be set in the instances should be
>> declared in the properties data file.
>>
>> Please be more specific, and file a bug with the details.
>>
>> Which data file are you using and which null values are incorrect?
>>
>> Thanks,
>>
>> Craig
>>
>> On Apr 5, 2006, at 5:21 PM, Erik Bengtson wrote:
>>
>>>
>>>
>>> Hi,
>>>
>>> The completeness test uses Spring for creating instances. Spring
>>> sets values
>>> using the constructors, but for the interface test the generated
>>> implementations have only a default constructor, so instances  
>>> will be
>>> constructed with null values.
>>>
>>> Later the JDO vendor impl will attempt to store instances in not
>>> null columns,
>>> and this fails.
>>>
>>> Regards,
>>
>> 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