Hi,

> It works great except when it comes to extents.
> In this case,
> *EmployeeRhBr extends Employee => How should I reflect this in the
> repository mapping? Do I make some mistake somewhere?

Add EmployeeRhBr as extent to Employee class-descriptor.

Additional you can refactoring your extent handling:

<class-descriptor class="sj.employee.bean.Employee">
  <extent-class class-ref="sj.employeeRh.bean.EmployeeImpl"/>
  <extent-class class-ref="sj.employeeRh.bean.EmployeeRh"/>
  <extent-class class-ref="*more extended Interface*"/>
  ...
</class-descriptor>

<class-descriptor class="sj.employee.bean.EmployeeRhBr">
   <extent-class class-ref="sj.employeeRhBr.bean.EmployeeRhBrImpl"/>
</class-descriptor>

<class-descriptor class="dummy.Name">
  <extent-class class-ref="dummy.NameImpl"/>
</class-descriptor>

only declare EmplyeeImpl and all extended interfaces of Employee, because you declare all NameImpl classes in the dummy.Name class-descriptor again.
Hope this will work for you - good luck ;-)


regards,
Armin

Reda Benzair wrote:



I think your "extent-class declaration" cause the problem (Or OJB's handling of extent clases).
EmployeeRhBr is an interface that extends Employee interface? EmployeeRhBrImpl is an extent of Employee AND EmployeeRhBr. Why? Maybe this cause the problem.


Of course this causes the problem : When I call new
Identity(employee505, pb), the "detected" top level class is not
Employee but EmployeeRhBr.

In my repository every class-descriptor looks like

Repository.xml:
<class-descriptor class="dummy.Name">
        <extent-class class-ref="dummy.NameImpl"/>
 </class-descriptor>
 <class-descriptor class="dummy.NameImpl" table="DUMMY_TABLE">
        <!-- .............. -->
 </class-descriptor>

Name.java:
package dummy;

public interface Name {
//.............
}

NameImpl.java
package dummy;

public class NameImpl implements Name {
//.............
}



The interface is there to allow proxies.

It works great except when it comes to extents.
In this case, *EmployeeRhBr extends Employee => How should I reflect this in the
repository mapping? Do I make some mistake somewhere?


Thank you for all the time you spend on my question! :)



-----Original Message-----
From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: lundi 29 décembre 2003 16:14
To: OJB Users List
Subject: Re: [detail] reload Object ? ? (Problem Cache)


Hi,

 >>How can I force refreshing an object? Typically is there a method
like  >>PB.refreshObject(Object o)? -I know of course this one doesn't

> exist...-


yes, you only can perform a refresh operation on the references. If you
remove an object from the cache, next time you lookup the same object (same Identity/PK) OJB materialize a new object instance.


Reda Benzair wrote:

You're right. Sorry.

The third line is the one I get after I call pb.clearCache(). And it's


the one I would rather get instead of line 2.


I add a similar test case to test suite (see ...broker.ObjectCacheTest#testObjectCacheDefaultImpl in CVS). This test pass without any problems. If the object was removed from cache, the object was read from the DB.



Something I noticed since I posted this message : This sample code

works


great if the query concerns "classical" classes instead of Employee : Employee is an extent.



hmm, seems to be an Identity problem. In OJB Identity class two objects are equals
a) if they had the same TopLevelClass (in your case interface Employee)
b) and the same PK values (don't know what the PK fields of your Employee implementation classes are)


I think your "extent-class declaration" cause the problem (Or OJB's handling of extent clases).
EmployeeRhBr is an interface that extends Employee interface?
EmployeeRhBrImpl is an extent of Employee AND EmployeeRhBr. Why? Maybe
this cause the problem.


regards,
Armin


<class-descriptor class="sj.employee.bean.Employee">
        <extent-class class-ref="sj.employee.bean.EmployeeImpl"/>
        <extent-class class-ref="sj.employeeRh.bean.EmployeeRhImpl"/>
        <extent-class class-ref="sj.employeeBr.bean.EmployeeBrImpl"/>
        <extent-class

class-ref="sj.employeeRhBr.bean.EmployeeRhBrImpl"/>


</class-descriptor>
<class-descriptor class="sj.employee.bean.EmployeeImpl"
table="EMPLOYEE">
        <!-- .............. -->
</class-descriptor>
<!-- .............. -->
<class-descriptor class="sj.employee.bean.EmployeeRhBr">
        <extent-class
class-ref="sj.employeeRhBr.bean.EmployeeRhBrImpl"/>
</class-descriptor>
<class-descriptor class="sj.employee.bean.EmployeeRhBrImpl"
table="EMPLOYEE">
        <!-- .............. -->
</class-descriptor>

=> If I create a new Identity(employee505, pb), the resulting object does not match (.equals + .hascode) the one that already exists in the


cache : removeFromCache has no effect, wich explains the strange behaviour above. As a workaround, I have removed all extents from my repository but it's a shame...

What should I do?


-----Original Message----- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: mardi 23 décembre 2003 01:42 To: OJB Users List Subject: Re: reload Object ? ? (Problem Cache)

Hi,

in your example only 2 System.out.println(..) lines performed, but 3
lines are printed?! Do you forget one println() statement?

regards,
Armin

Reda Benzair wrote:


Hi all,



I have a -simple?- question about OJB cache:



How can I force refreshing an object? Typically is there a method like


PB.refreshObject(Object o)? -I know of course this one doesn't

exist...-




To be more precise, I have someting like this:


PersistenceBroker pb =
PersistenceBrokerFactory.createPersistenceBroker("jcd", "user",

"pass");



Criteria crit = new Criteria();
crit.addEqualTo("Id", new Integer(505));
Employee employee505 = (Employee) pb.getObjectByQuery(new
QueryByCriteria(Employee.class, crit));

System.out.println("ID 505 = " + employee505.getName() + " " +
employee505);

employee505.setName("MODIFIED " + employee505.getName());
// modified but not stored... should be erased by remove + reload? pb.removeFromCache(employee505);
employee505 = (Employee) pb.getObjectByQuery(new QueryByCriteria(Employee.class, crit));


System.out.println("505 = " + employee505.getName() + " " +
employee505);


> >

The standard output is:

505 = John Doe [EMAIL PROTECTED]

505 = MODIFIED john Doe [EMAIL PROTECTED]

505 = John Doe [EMAIL PROTECTED]

And I would have liked line2 to be exactly equal to line1. Where am I
wrong?



Thank you very much by advance, since this blocks my team on the
production environment...








---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]






--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to