Hi Bobby,
I wrote a test case using VARCHAR as PK,FK columns similar to yours (auto-retrieve for the 1:1 reference is 'false'). This test pass with latest from CVS.
Did you try latest version from CVS (OJB_1_0_RELEASE branch)?
regards, Armin
The test:
String name = "testAutoRetrieveFalse_" + System.currentTimeMillis();
Contract contract = new Contract();
contract.setPk("C"+System.currentTimeMillis());
contract.setContractValue1(name + "_Contract");
contract.setContractValue2(1);
contract.setContractValue3("contractvalue3");
contract.setContractValue4(new Timestamp(System.currentTimeMillis()));
RelatedToContract rc = new RelatedToContract(); rc.setPk("R_" + System.currentTimeMillis()); rc.setRelatedValue1(name + "_RelatedToContract");
contract.setRelatedToContract(rc); broker.beginTransaction(); // auto-update is true broker.store(contract); broker.commitTransaction();
broker.clearCache(); Identity oid = broker.serviceIdentity().buildIdentity(contract); Contract newC = (Contract) broker.getObjectByIdentity(oid); // auto-retireve is false assertNotNull(newC); assertNull(newC.getRelatedToContract());
broker.retrieveAllReferences(newC);
assertNotNull(newC.getRelatedToContract());
Bobby Lawrence wrote:
I am using the PersistenceBroker API and the error is happening in the retrieveReferences method.
--B
Clute, Andrew wrote:
Which API are you using? What does your criteria look like?
Without knowing much about how you are selecting your data, I am going to guess that you are doing a 'addEqualToColumn' as opposed to 'addEqualTo'. The first one assumes the String you pass in is a column name (hence the lack of quotes around it), versus the value of a column.
-Andrew
-----Original Message-----
From: Bobby Lawrence [mailto:[EMAIL PROTECTED] Sent: Thursday, March 10, 2005 5:20 PM
To: ojb-user@db.apache.org
Subject: VARCHAR columns?
I have a table called projects. Given a project_id (VARCHAR) in one table, I want to look up the project object from the projects table. The projects table has a primary key (project_id) that is also defined as a VARCHAR. Problem is, when OJB writes the select statement, it doesn't include the single quotes in the where clause. It creates the SQL like this: ---------------------------------------------------------- SELECT A0.PROJECT_ID,
A0.LAST_NAME,
A0.FIRST_NAME,
A0.ORG_ID,
A0.EMAIL_ADDRESS,
A0.USER_NAME FROM PROJECTS A0
WHERE A0.PROJECT_ID = SDC010 ----------------------------------------------------------
Is this a bug? Am I doing something wrong?
Repo.xml ----
<class-descriptor class="org.jlab.mis.services.mics.client.generated.ComputingJob" table="jobs"> <field-descriptor name="beginTime" column="STIME" jdbc-type="TIMESTAMP" primarykey="true" conversion="org.apache.ojb.broker.accesslayer.conversions.Calendar2Times tampFieldConversion"/> <field-descriptor name="endTime" column="ETIME" jdbc-type="TIMESTAMP" conversion="org.apache.ojb.broker.accesslayer.conversions.Calendar2Times tampFieldConversion"/> <field-descriptor name="queuedTime" column="QUEUED_TIME" jdbc-type="TIMESTAMP" conversion="org.apache.ojb.broker.accesslayer.conversions.Calendar2Times tampFieldConversion"/> <field-descriptor name="numNodesUsed" column="NODE_COUNT" jdbc-type="INTEGER"/> <field-descriptor name="numCpusUsed" column="CPU_COUNT" jdbc-type="INTEGER"/> <field-descriptor name="chargeFactor" column="CHARGE_FACTOR" jdbc-type="DOUBLE"/> <field-descriptor name="projectId" column="PROJECT_ID" jdbc-type="VARCHAR" access="anonymous"/> <reference-descriptor name="projectJobAllocatedAgainst" class-ref="org.jlab.mis.services.mics.client.generated.Project"> <foreignkey field-ref="projectId"/> </reference-descriptor> </class-descriptor>
<class-descriptor class="org.jlab.mis.services.mics.client.generated.Project" table="projects"> <field-descriptor name="id" column="PROJECT_ID" jdbc-type="VARCHAR" primarykey="true"/> <field-descriptor name="name" column="PROJECT_NAME" jdbc-type="VARCHAR" /> <field-descriptor name="initialAllocation" column="TOTAL_HOURS" jdbc-type="BIGINT" /> <field-descriptor name="fiscalYear" column="FISCAL_YEAR" jdbc-type="VARCHAR" /> </class-descriptor>
Has anyone else experienced this?
-- ---------------------------- Bobby Lawrence MIS Application Developer
Jefferson Lab (www.jlab.org)
Email: [EMAIL PROTECTED] Office: (757) 269-5818 Pager: (757) 584-5818 ----------------------------
--------------------------------------------------------------------- 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]