Re: [OJB-developers] "constant" values in where clause
Brought to you by:
thma
From: Thomas M. <tho...@ho...> - 2001-12-10 17:28:56
|
Hi Matt, > Matt Goodall wrote: > > Hi, > > I'm still trying to understand what's actually possible with OJB ... > > If I have a table defined something like this: > > type varchar(xxx) > short_name varchar(yyy) > long_name varchar(zzz) > > which might hold the following: > > "vehicle", "car", "small thing which can't seem to hold more that > one person at a time" > "vehicle", "train", "long thing which is always late" > "fruit", "apple", "green or red round thing" > "fruit", "mango", "yum, yum" > "fruit", "banana", "yellow, long and bendy. great with custard" > ... etc, I'm sure you get the idea by now ;) > When I get you right you want to map different Java classes (Vehicle, Fruit) onto one table. The column "type" is used as a type identifier. This is a scenario is described in tutorial3 in section "mapping inheritance hierachies" in the subsection "mapping all classes on the same table". By default OJB expects a full qualified classname in the column "type". If this is not viable for your, you can implement a RowReader with a special implementation of the method selectClassDescriptor(...). This is needed to map your names "vehicle" and "fruit" to real classnames like "my.own.com.Vehicle" and "my.own.com.Fruit". > Can I tell OJB that I have a class called Fruit with public name and > description properties and ask OJB for all Fruit (for example) without > having to qualify that type='fruit' i.e. supply no Criteria to the > query and only get a list of fruit back? > // select all fruits: Query q = QueryFactory.newQuery(Fruit.class, null); HTH, Thomas > Thanks, Matt > --- > Matt Goodall > Analyst Programmer, Strategic Systems Solutions > e: mat...@ss..., t: +44 113 3892645 > |