Title: Message
I have two simple tables, product and category, that has a 1-to-1 relation.
product has a column named category_id which maps to table category (id).
category has 2 columns: id, name.
 
Part of the mapping.xml looks like this:
<mapping>
 <class name="Product" identity="prod_id" access="read-only">
  <map-to table="db.product" />
 
  <field name="productId" type="integer">
   <sql name="prod_id" type="numeric" />
  </field>
  ... snip
  <field name="categoryId" type="Category">
   <sql name="category_id" />
  </field>
  ... snip
 </class>
</mapping>
 
<mapping>
 <class name="Category" identity="id" access="read-only">
  <map-to table="db.category" />
 
  <field name="categoryId" type="string">
   <sql name="id" type="char" />
  </field>
  <field name="name" type="string">
   <sql name="name" type="varchar" />
  </field>
 </class>
</mapping>
 
The problem is that whenever I select something from
Object Product, Category object inside Product sometimes gets "null" and
it sometimes gets the right value from the database.
 
The java source code looks something like this:
 
db = jdo.getDatabase();
db.begin();
 
oql = db.getOQLQuery("SELECT o FROM Product o " +
       "WHERE o.categoryId LIKE $1 ");
oql.bind(category);
 
results = oql.execute(true);
 
if (page > 1) results.absolute((page-1)*pageSize);
totalCount = results.size();
 
for (int i=0; i<pageSize && results.hasMore(); i++) {
 list.add(results.next());
}
 
db.commit();
 
I'm using WebLogic 6.1 along with JDO 0.9.4.2.
Thanks.

Reply via email to