You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Brian Latimer <bl...@apcc.aspca.org> on 2004/06/04 22:13:30 UTC
Cascading anonymous keys
I have many persistent objects that contain references to other persistent
objects.
I am fairly certain that I have the mapping set up properly, but, the
auto-retrive doesn't seem to cascade down my objects if they use anonymous
keys. That is unless I use proxies; in which case the objects get loaded
correctly when methods are called. So I can get the results I want, but I
don't necessarily want to use proxies.
Let's say for instance class A contains an instance of class B and B has an
instance of class C.
If I do not use anonymous keys, but instead put the foreign keys in the
classes, everything will auto-load when I call a
getCollectionByCriteria(classA). Thus when I call a method on a class C
contained within any given instance of class A from my collection
everything works.
If I then change ONLY one thing, and add access="anonymous" to a foreign
key field, the cascade seems to fail and class C will show up as null.
If I then again change ONLY one thing and add proxy="dynamic" to class A,
the method call against class C will again function properly when called
(as I would expect it to)
Is this the expected behavior, that anonymous keys do not auto-retrieve all
the way in a collection, or should my anonymous keys auto-retrieve all the
way down the class structure?
any help would be appreciated. If needed, I can post code and repository
files, but I was hoping to describe the problem clearly enough to avoid that.
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Cascading anonymous keys
Posted by Brian Latimer <bl...@apcc.aspca.org>.
>I have encountered an error that I think may be related to my other
>anonymous key issues.
Some of my objects have references with FK values of 0.
I had been using primitives for many of these, but I have gone back and
updated all my key fields to be classes. I think this may have contributed
to my
earlier issues.
However, when I try to access an object with a FK value of 0 that is using
an anonymous key I get a null pointer exception.
If I don't use anonymous keys, I don't have this problem.
Do anonymous keys use primitives?
Any ideas or workarounds?
Here is the stacktrace, though it isn't very interesting.
java.lang.NullPointerException
at org.apache.ojb.broker.util.BrokerHelper.representsNull(Unknown
Source)
at
org.apache.ojb.broker.core.QueryReferenceBroker.hasNullifiedFK(Unknown Source)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getReferencedObjectIdentity(Unknown
Source)
at
org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReference(Unknown
Source)
at
org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReferences(Unknown
Source)
at
org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unknown
Source)
at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown
Source)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown
Source)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown
Source)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown
Source)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown
Source)
at
org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl.loadData(Unknown
Source)
at
org.apache.ojb.broker.core.proxy.ListProxyDefaultImpl.loadData(Unknown Source)
at
org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl.getData(Unknown
Source)
at
org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl.iterator(Unknown
Source)
at
org.apache.taglibs.standard.tag.common.core.ForEachSupport.toForEachIterator(Unknown
Source)
at
org.apache.taglibs.standard.tag.common.core.ForEachSupport.supportedTypeForEachIterator(Unknown
Source)
at
org.apache.taglibs.standard.tag.common.core.ForEachSupport.prepare(Unknown
Source)
at javax.servlet.jsp.jstl.core.LoopTagSupport.doStartTag(Unknown
Source)
at
org.apache.jsp.pages.StaffDirectory_jspx._jspx_meth_c_forEach_1(StaffDirectory_jspx.java:297)
at
org.apache.jsp.pages.StaffDirectory_jspx._jspx_meth_c_forEach_0(StaffDirectory_jspx.java:263)
at
org.apache.jsp.pages.StaffDirectory_jspx._jspService(StaffDirectory_jspx.java:148)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at
org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
at
org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:582)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:260)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
at java.lang.Thread.run(Thread.java:534)
[org.apache.ojb.broker.cache.InternalCache] ERROR: Found 1 abandoned
objects in local cache, check code to force push to real ObjectCache
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Cascading anonymous keys
Posted by Armin Waibel <ar...@apache.org>.
Hi Brian,
Brian Latimer wrote:
> Armin,
>
> I have tried my code with rc7 and I still have the problem I described.
>
> Looking at the test case you have written, it seems to produce the
> results I would like. That is, your code does not return null objects
> for objects that should be retrieved via anonymous foreign keys
> contained within nested objects.
>
> The only major difference I have seen between your test case and my code
> thus far is that you have a reference to a "Person" within the
> PersonDetail.
This shouldn't be a problem. In the test I set auto-retrieve to false
for this reference. But I will try to run the test without the reference
to be sure.
>
> public static class PersonDetail implements PersonDetailIF
> {
> Integer id;
> String profile;
> Person person; // <------------------------- I don't have
> this reference
> GenderIF gender;
> ...
>
> I tried adding a reference like you have but ended up with the same
> results that I had without such a reference.
>
> My code looks very much like your test case, but I still get nulls on my
> nested objects if I use anonymous keys and turn proxies off.
> While I think you have shown that the problems must be with my code
> somewhere, I'm certainly baffled as to what might be wrong.
>
> I am using PersistentFieldIntrospectorImpl and most of my properties are
> private, do you suppose that would cause a problem on nested objects?
>
I run PrimaryKeyForeignKeyTest.java with PersistentFieldIntrospectorImpl
but all tests pass, thus it seems that this isn't the problem.
A difference between your test and PrimaryKeyForeignKeyTest is that you
using another SequenceManager to generate the PK values (assume you are
using SequenceManagerNativeImpl, because PK was set to 'readonly'). I
don't know if this could be a problem, maybe you try to run your test
with another SequenceManager (e.g. SequenceManagerInMemoryImpl and non
Identity column for PK).
regards,
Armin
> Thank you very much for looking into this for me.
> Brian
>
> At 08:58 AM 06/12/2004, Armin Waibel wrote:
>
>> Hi Brian,
>>
>> I tried to reproduce your problem (with latest from CVS) without
>> success. A new test case was added to test suite
>> ([db-ojb]/src/test/org/...) called PrimaryKeyForeignKeyTest.java, the
>> mapping is declared in repository_junit_reference.
>> Please have a look at this test, does it reproduce your problem?
>>
>> regards,
>> Armin
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Cascading anonymous keys
Posted by Brian Latimer <bl...@apcc.aspca.org>.
Armin,
I have tried my code with rc7 and I still have the problem I described.
Looking at the test case you have written, it seems to produce the results
I would like. That is, your code does not return null objects for objects
that should be retrieved via anonymous foreign keys contained within nested
objects.
The only major difference I have seen between your test case and my code
thus far is that you have a reference to a "Person" within the PersonDetail.
public static class PersonDetail implements PersonDetailIF
{
Integer id;
String profile;
Person person; // <------------------------- I don't have this
reference
GenderIF gender;
...
I tried adding a reference like you have but ended up with the same results
that I had without such a reference.
My code looks very much like your test case, but I still get nulls on my
nested objects if I use anonymous keys and turn proxies off.
While I think you have shown that the problems must be with my code
somewhere, I'm certainly baffled as to what might be wrong.
I am using PersistentFieldIntrospectorImpl and most of my properties are
private, do you suppose that would cause a problem on nested objects?
Thank you very much for looking into this for me.
Brian
At 08:58 AM 06/12/2004, Armin Waibel wrote:
>Hi Brian,
>
>I tried to reproduce your problem (with latest from CVS) without success.
>A new test case was added to test suite ([db-ojb]/src/test/org/...) called
>PrimaryKeyForeignKeyTest.java, the mapping is declared in
>repository_junit_reference.
>Please have a look at this test, does it reproduce your problem?
>
>regards,
>Armin
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Cascading anonymous keys
Posted by Armin Waibel <ar...@apache.org>.
Hi Brian,
I tried to reproduce your problem (with latest from CVS) without
success. A new test case was added to test suite
([db-ojb]/src/test/org/...) called PrimaryKeyForeignKeyTest.java, the
mapping is declared in repository_junit_reference.
Please have a look at this test, does it reproduce your problem?
regards,
Armin
Brian Latimer wrote:
> At 06:09 PM 06/09/2004, Armin Waibel wrote:
>
>> Hi Brian,
>>
>> sounds strange, do you use the anonymous keys in a 1:1 or 1:n
>> relation? Which version do you use? Have you tried latest from CVS?
>> Can you describe me detailed a test case to reproduce the problem?
>
>
> I'm using rc6. I have not tried the latest CVS version.
>
> In the case causing problems, I think I am using anonymous keys only in
> 1:1 relations.
>
> Here are the relevant code chunks
>
> /********************************** Method to access database
> ***************************************/
> public Collection getCollection(Object obj, String key, Object value)
> throws DataAccessException {
>
> Criteria criteria = null;
> Collection result = null;
> PersistenceBroker broker = null;
> QueryByCriteria query = null;
>
> if (obj == null)
> return result;
> try {
> broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> // Create criteria.
> criteria = new Criteria();
> criteria.addEqualTo(key, value); // Refine criteria
> // Create Query
> query = new QueryByCriteria(obj.getClass(), criteria);
> result = broker.getCollectionByQuery(query);
> } catch (Exception e) {
> System.out.println("Error in getCollection: " + e.getMessage());
> } finally {
> if (broker != null)
> broker.close(); // Release broker instance to the
> broker-pool
> }
>
> return result;
> }
>
> /******************************* Method calling getCollection
> ******************************/
> public Collection getActiveEmployees() {
> EmployeeBean staff = new EmployeeBean();
> Vector staffList = new Vector();
>
> try{
> staffList = (Vector) dao.getCollection(staff,
> "statusTypeId", new Integer(1)); //@todo cleanup
> }
> catch (Exception e) {
> System.out.println("Error in getEmployees: " + e.getMessage());
> }
> return staffList;
> }
>
>
> /**************************************** repository
> ****************************************/
> <class-descriptor class="alpha.EmployeeBean" table="OPS.STAFFLIST">
> <field-descriptor name="id" primarykey="true" default-fetch="true"
> column="STAFFID" jdbc-type="SMALLINT" autoincrement="true"
> access="readonly"/>
> <field-descriptor name="firstName" default-fetch="true"
> column="FIRSTNAME" jdbc-type="CHAR"/>
> <field-descriptor name="middleName" default-fetch="true"
> column="MIDDLENAME1" jdbc-type="CHAR"/>
> <field-descriptor name="lastName" nullable="false"
> default-fetch="true" column="LASTNAME" jdbc-type="CHAR"/>
> <field-descriptor name="aspcaId" nullable="false"
> default-fetch="true" column="ASPCAID" jdbc-type="SMALLINT"/>
> <field-descriptor name="staffTypeId" nullable="false"
> default-fetch="true" column="STAFFTYPEID" jdbc-type="SMALLINT"/>
> <field-descriptor name="statusTypeId" nullable="false"
> default-fetch="true" column="STATUSTYPEID" jdbc-type="SMALLINT"/>
> <field-descriptor name="login" default-fetch="true"
> column="LOGINNAME" jdbc-type="CHAR"/>
>
> <reference-descriptor
> name="details"
> class-ref="alpha.PersonDetailsBean"
> auto-retrieve="true"
> proxy="true">
> <foreignkey field-ref="id"/>
> </reference-descriptor>
> <collection-descriptor
> name="phoneNumbers"
> element-class-ref="alpha.PhoneNumberBean"
> proxy="true"
> >
> <inverse-foreignkey field-ref="callerId"/>
> </collection-descriptor>
> <collection-descriptor
> name="addresses"
> element-class-ref="alpha.AddressBean"
> proxy="true"
> >
> <inverse-foreignkey field-ref="id"/>
> </collection-descriptor>
> </class-descriptor>
>
>
> <class-descriptor class="alpha.PersonDetailsBean" table="OPS.STAFFDETAIL">
> <field-descriptor name="id" primarykey="true"
> default-fetch="true" column="STAFFID" jdbc-type="SMALLINT" />
> <field-descriptor name="genderId" nullable="false"
> column="GENDERTYPEID" jdbc-type="SMALLINT" access="anonymous" />
> <field-descriptor name="maritalStatusId"
> nullable="false" column="MARITALTYPEID" jdbc-type="SMALLINT"
> access="anonymous"/>
> <field-descriptor name="dateOfBirth" default-fetch="true"
> column="BIRTHDATE" jdbc-type="DATE"/>
> <field-descriptor name="whenEntered" nullable="false"
> default-fetch="true" column="WHENENTERED" jdbc-type="TIMESTAMP"/>
> <field-descriptor name="notes" default-fetch="true"
> column="BIOSKETCH" jdbc-type="VARCHAR"/>
>
> <reference-descriptor
> name="maritalStatus"
> class-ref="alpha.MaritalStatusBean"
> auto-retrieve="true">
> <foreignkey field-ref="maritalStatusId"/>
> </reference-descriptor>
> <reference-descriptor
> name="gender"
> class-ref="alpha.GenderBean"
> auto-retrieve="true">
> <foreignkey field-ref="genderId"/>
> </reference-descriptor>
>
> </class-descriptor>
>
>
> <class-descriptor class="alpha.GenderBean" table="OPS.GENDERTYPE">
> <field-descriptor name="id" primarykey="true"
> default-fetch="true" column="GENDERTYPEID" jdbc-type="SMALLINT"/>
> <field-descriptor name="name" nullable="false"
> default-fetch="true" column="GENDERTYPENAME" jdbc-type="CHAR"/>
> <field-descriptor name="dscrp" default-fetch="true"
> column="GENDERTYPEDSCRP" jdbc-type="CHAR"/>
> <field-descriptor name="whenEntered" nullable="false"
> default-fetch="true" column="WHENENTERED" jdbc-type="TIMESTAMP"/>
> </class-descriptor>
> <class-descriptor class="alpha.MaritalStatusBean" table="OPS.MARITALTYPE">
> <field-descriptor name="id" primarykey="true"
> default-fetch="true" column="MARITALTYPEID" jdbc-type="SMALLINT"/>
> <field-descriptor name="name" nullable="false"
> default-fetch="true" column="MARITALTYPENAME" jdbc-type="CHAR"/>
> <field-descriptor name="dscrp" default-fetch="true"
> column="MARITALTYPEDSCRP" jdbc-type="CHAR"/>
> <field-descriptor name="whenEntered" nullable="false"
> default-fetch="true" column="WHENENTERED" jdbc-type="TIMESTAMP"/>
> </class-descriptor>
>
> /******************************************************* What happens
> *********************************************/
> The code above is producing the results I want, but I am forced to use
> proxies.
> IF I remove the proxy="true" from PersonDetailsBean, then the
> MaritalStatus and GenderBean contained within are both null when I
> attempt to access them even though auto-retrieve="true". However the
> PersonDetailsBean itself is not null and I can access properties such as
> dateOfBirth just fine.
>
>
>
>
>> thanks much for any suggestions,
>
>
> Brian
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Cascading anonymous keys
Posted by Brian Latimer <bl...@apcc.aspca.org>.
At 06:09 PM 06/09/2004, Armin Waibel wrote:
>Hi Brian,
>
>sounds strange, do you use the anonymous keys in a 1:1 or 1:n relation?
>Which version do you use? Have you tried latest from CVS?
>Can you describe me detailed a test case to reproduce the problem?
I'm using rc6. I have not tried the latest CVS version.
In the case causing problems, I think I am using anonymous keys only
in 1:1 relations.
Here are the relevant code chunks
/********************************** Method to access
database ***************************************/
public Collection getCollection(Object obj, String key, Object value)
throws DataAccessException {
Criteria criteria = null;
Collection result = null;
PersistenceBroker broker = null;
QueryByCriteria query = null;
if (obj == null)
return result;
try {
broker = PersistenceBrokerFactory.defaultPersistenceBroker();
// Create criteria.
criteria = new Criteria();
criteria.addEqualTo(key, value); // Refine criteria
// Create Query
query = new QueryByCriteria(obj.getClass(), criteria);
result = broker.getCollectionByQuery(query);
} catch (Exception e) {
System.out.println("Error in getCollection: " + e.getMessage());
} finally {
if (broker != null)
broker.close(); // Release broker instance to the
broker-pool
}
return result;
}
/******************************* Method calling getCollection
******************************/
public Collection getActiveEmployees() {
EmployeeBean staff = new EmployeeBean();
Vector staffList = new Vector();
try{
staffList = (Vector) dao.getCollection(staff, "statusTypeId",
new Integer(1)); //@todo cleanup
}
catch (Exception e) {
System.out.println("Error in getEmployees: " + e.getMessage());
}
return staffList;
}
/**************************************** repository
****************************************/
<class-descriptor class="alpha.EmployeeBean" table="OPS.STAFFLIST">
<field-descriptor name="id" primarykey="true" default-fetch="true"
column="STAFFID" jdbc-type="SMALLINT" autoincrement="true"
access="readonly"/>
<field-descriptor name="firstName" default-fetch="true"
column="FIRSTNAME" jdbc-type="CHAR"/>
<field-descriptor name="middleName" default-fetch="true"
column="MIDDLENAME1" jdbc-type="CHAR"/>
<field-descriptor name="lastName" nullable="false"
default-fetch="true" column="LASTNAME" jdbc-type="CHAR"/>
<field-descriptor name="aspcaId" nullable="false" default-fetch="true"
column="ASPCAID" jdbc-type="SMALLINT"/>
<field-descriptor name="staffTypeId" nullable="false"
default-fetch="true" column="STAFFTYPEID" jdbc-type="SMALLINT"/>
<field-descriptor name="statusTypeId" nullable="false"
default-fetch="true" column="STATUSTYPEID" jdbc-type="SMALLINT"/>
<field-descriptor name="login" default-fetch="true"
column="LOGINNAME" jdbc-type="CHAR"/>
<reference-descriptor
name="details"
class-ref="alpha.PersonDetailsBean"
auto-retrieve="true"
proxy="true">
<foreignkey field-ref="id"/>
</reference-descriptor>
<collection-descriptor
name="phoneNumbers"
element-class-ref="alpha.PhoneNumberBean"
proxy="true"
>
<inverse-foreignkey field-ref="callerId"/>
</collection-descriptor>
<collection-descriptor
name="addresses"
element-class-ref="alpha.AddressBean"
proxy="true"
>
<inverse-foreignkey field-ref="id"/>
</collection-descriptor>
</class-descriptor>
<class-descriptor class="alpha.PersonDetailsBean" table="OPS.STAFFDETAIL">
<field-descriptor name="id" primarykey="true"
default-fetch="true" column="STAFFID" jdbc-type="SMALLINT" />
<field-descriptor name="genderId" nullable="false"
column="GENDERTYPEID" jdbc-type="SMALLINT" access="anonymous" />
<field-descriptor name="maritalStatusId" nullable="false"
column="MARITALTYPEID" jdbc-type="SMALLINT" access="anonymous"/>
<field-descriptor name="dateOfBirth" default-fetch="true"
column="BIRTHDATE" jdbc-type="DATE"/>
<field-descriptor name="whenEntered" nullable="false"
default-fetch="true" column="WHENENTERED" jdbc-type="TIMESTAMP"/>
<field-descriptor name="notes" default-fetch="true"
column="BIOSKETCH" jdbc-type="VARCHAR"/>
<reference-descriptor
name="maritalStatus"
class-ref="alpha.MaritalStatusBean"
auto-retrieve="true">
<foreignkey field-ref="maritalStatusId"/>
</reference-descriptor>
<reference-descriptor
name="gender"
class-ref="alpha.GenderBean"
auto-retrieve="true">
<foreignkey field-ref="genderId"/>
</reference-descriptor>
</class-descriptor>
<class-descriptor class="alpha.GenderBean" table="OPS.GENDERTYPE">
<field-descriptor name="id" primarykey="true"
default-fetch="true" column="GENDERTYPEID" jdbc-type="SMALLINT"/>
<field-descriptor name="name" nullable="false"
default-fetch="true" column="GENDERTYPENAME" jdbc-type="CHAR"/>
<field-descriptor name="dscrp" default-fetch="true"
column="GENDERTYPEDSCRP" jdbc-type="CHAR"/>
<field-descriptor name="whenEntered" nullable="false"
default-fetch="true" column="WHENENTERED" jdbc-type="TIMESTAMP"/>
</class-descriptor>
<class-descriptor class="alpha.MaritalStatusBean" table="OPS.MARITALTYPE">
<field-descriptor name="id" primarykey="true"
default-fetch="true" column="MARITALTYPEID" jdbc-type="SMALLINT"/>
<field-descriptor name="name" nullable="false"
default-fetch="true" column="MARITALTYPENAME" jdbc-type="CHAR"/>
<field-descriptor name="dscrp" default-fetch="true"
column="MARITALTYPEDSCRP" jdbc-type="CHAR"/>
<field-descriptor name="whenEntered" nullable="false"
default-fetch="true" column="WHENENTERED" jdbc-type="TIMESTAMP"/>
</class-descriptor>
/******************************************************* What happens
*********************************************/
The code above is producing the results I want, but I am forced to use proxies.
IF I remove the proxy="true" from PersonDetailsBean, then the MaritalStatus
and GenderBean contained within are both null when I attempt to access them
even though auto-retrieve="true". However the PersonDetailsBean itself is
not null and I can access properties such as dateOfBirth just fine.
>thanks much for any suggestions,
Brian
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Cascading anonymous keys
Posted by Armin Waibel <ar...@apache.org>.
Hi Brian,
sounds strange, do you use the anonymous keys in a 1:1 or 1:n relation?
Which version do you use? Have you tried latest from CVS?
Can you describe me detailed a test case to reproduce the problem?
regards,
Armin
Brian Latimer wrote:
> I have many persistent objects that contain references to other
> persistent objects.
>
> I am fairly certain that I have the mapping set up properly, but, the
> auto-retrive doesn't seem to cascade down my objects if they use
> anonymous keys. That is unless I use proxies; in which case the objects
> get loaded correctly when methods are called. So I can get the results
> I want, but I don't necessarily want to use proxies.
>
> Let's say for instance class A contains an instance of class B and B has
> an instance of class C.
>
> If I do not use anonymous keys, but instead put the foreign keys in the
> classes, everything will auto-load when I call a
> getCollectionByCriteria(classA). Thus when I call a method on a class C
> contained within any given instance of class A from my collection
> everything works.
>
> If I then change ONLY one thing, and add access="anonymous" to a foreign
> key field, the cascade seems to fail and class C will show up as null.
>
> If I then again change ONLY one thing and add proxy="dynamic" to class
> A, the method call against class C will again function properly when
> called (as I would expect it to)
>
> Is this the expected behavior, that anonymous keys do not auto-retrieve
> all the way in a collection, or should my anonymous keys auto-retrieve
> all the way down the class structure?
>
> any help would be appreciated. If needed, I can post code and
> repository files, but I was hoping to describe the problem clearly
> enough to avoid that.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org