Hi Armin I'm using BaseBusinessBean class merely to avoid creating getter/setter methods for common fields: id & description in all my value objects.
I don't think I new what 'extent' means (how it's used) in OJB. :) In my repository_user.xml, I removed the class-descriptor for BaseBusinessBean class. This was not needed in my situation. :) It all works fine now. --Alen ----- Original Message ----- From: "Armin Waibel" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Monday, June 16, 2003 7:20 AM Subject: Re: Help, wrong table being looked up! > Hi Alen, > > don't know if this will solve your problem, but I see two > problematic things > > - Product and Category have to be 'extent aware'. > see > http://db.apache.org/ojb/sequencemanager.html#extentAware > Means > the id's have to be unique across all tables of all extent classes > of BaseBusinessBean descriptor. You say that in Product and Category > table both entities have id with value '1'!! Something going wrong. > > - Why did you define a BaseBusinessBean descriptor? Does this > make sense? Do you need to query 'give me all BaseBusinessBean'? > If not, don't declare such a descriptor (performance impact, reduce > number of possible id's per extent class - have to extent aware,...). > > regards, > Armin > > ----- Original Message ----- > From: "Alen Ribic" <[EMAIL PROTECTED]> > To: "OJB Users List" <[EMAIL PROTECTED]> > Sent: Sunday, June 15, 2003 11:37 PM > Subject: Re: Help, wrong table being looked up! > > > > Forgot one more thing... > > Looking at SQL generated by OJB, things look perfect from there. > > > > SELECT DISTINCT A0.description,A0.name,A0.id FROM category A0 WHERE id > like > > '%' order by name > > > > So, it is looking in Category table, but it's returning Product > object(s) as > > result. > > No idea... :) > > > > --Alen > > > > > > ----- Original Message ----- > > From: "Alen Ribic" <[EMAIL PROTECTED]> > > To: "OJB Users List" <[EMAIL PROTECTED]> > > Sent: Sunday, June 15, 2003 11:27 PM > > Subject: Help, wrong table being looked up! > > > > > > > Hi Everyone, > > > > > > I seem to be getting a strange problem in my persistence mechanism > using > > > OJB. > > > I'm using OJB ver: 1.0 rc2. > > > > > > I have two value objects named Category and Product. Each have own > DB > > table > > > there are mapped to. (same table names as class names) > > > Both have common fields (Id, description) hence such classes in my > system > > > inherit common fields from superclass BaseBusinessBean. > > > > > > > > > Message I get from the log is: > > > > > > 0 WARN [Thread-4] singlevm.PersistenceBrokerImpl - Candidate > object > > > [[1] Product test 01 price: 12.55 > > stock: > > > 8] class > > > [com.baroko.ebiz.model.Product] is not a subtype of > > > [com.baroko.ebiz.model.Cate > > > gory] or any type of proxy. NOT INCLUDED in result collection > > > > > > > > > As you can see above, OJB is pulling info from the wrong table. (In > this > > > case Product table instead of Category table) > > > It did the right thing with regards to the identity field. There is > only > > one > > > Id so far in Category table and that's Id: 1. But it looked up the > Id: 1 > > in > > > Product instead of Category table. > > > So, I got results for row where Id = 1 from Product instead of > Category > > > table. > > > > > > Here is my code snippet... > > > ... > > > broker set here.. > > > ... > > > public List apply(Object query) > > > throws PersistenceException { > > > ArrayList categoryList = null; > > > try { > > > if (!(query instanceof String)) > > > throw new PersistenceException( > > > Constants.PERSISTENCE_LIST_FAILED_INVALID_QUERY); > > > Criteria crt = new Criteria(); > > > crt.addSql((String)query); > > > QueryByCriteria queryByCriteria = > > > QueryFactory.newQuery(Category.class, crt, true); > > > Collection results = > broker.getCollectionByQuery(queryByCriteria); > > > categoryList = new ArrayList(results); > > > } catch(Exception ex) { > > > throw new PersistenceException( > > > Constants.PERSISTENCE_LIST_FAILED); > > > } > > > return (List)categoryList; > > > } > > > > > > > > > > > > Lastly the repository mappings... > > > > > > <!-- Definitions... --> > > > <class-descriptor > > > class="com.baroko.ebiz.model.Product" > > > table="product" > > > > > > > <field-descriptor id="8" > > > name="id" > > > column="id" > > > jdbc-type="INTEGER" > > > primarykey="true" > > > autoincrement="true" > > > /> > > > <field-descriptor id="9" > > > name="name" > > > column="name" > > > jdbc-type="VARCHAR" > > > /> > > > <field-descriptor id="10" > > > name="price" > > > column="price" > > > jdbc-type="FLOAT" > > > /> > > > <field-descriptor id="11" > > > name="stock" > > > column="stock" > > > jdbc-type="SMALLINT" > > > /> > > > <field-descriptor id="12" > > > name="description" > > > column="description" > > > jdbc-type="VARCHAR" > > > /> > > > </class-descriptor> > > > > > > > > > <class-descriptor > > > class="com.baroko.ebiz.model.Category" > > > table="category" > > > > > > > <field-descriptor id="13" > > > name="id" > > > column="id" > > > jdbc-type="SMALLINT" > > > primarykey="true" > > > autoincrement="true" > > > /> > > > <field-descriptor id="14" > > > name="name" > > > column="name" > > > jdbc-type="VARCHAR" > > > /> > > > <field-descriptor id="15" > > > name="description" > > > column="description" > > > jdbc-type="VARCHAR" > > > /> > > > </class-descriptor> > > > > > > <class-descriptor > > > class="com.baroko.ebiz.model.BaseBusinessBean" > > > > > > > <extent-class class-ref="com.baroko.ebiz.model.Category" /> > > > <extent-class class-ref="com.baroko.ebiz.model.Product" /> > > > </class-descriptor> > > > > > > > > > Note that I can get the list of products with no problems with > almost an > > > identical method as one above for category list. > > > > > > Sorry for inconvenience to anyone, if this is maybe some stupid > problem on > > > my side. > > > I just can't spot anything that would be causing this problem > especially > > > when it works fine with product list. > > > > > > Thanks > > > --Alen > > > > > > > > > > > > > --------------------------------------------------------------------- > > > 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]
