db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "TINE Houari (OBJECTIVA)" <houari.t...@ca-cedicam.fr>
Subject inheritance, extent and cleaner reference
Date Fri, 14 Mar 2003 12:34:11 GMT
Hi,

I finished ameliorations of OJB that consist of 

1. eliminating fk from 1-1 reference between objects.
2. implement inheritance as 1-1 reference.
3. eliminating the obligation of declaring the attribute ojbConcreteClass in
extent class.

The idea consists of introducing the concept of anonymous field descriptor
and anonymous persitent field.

case1: A reference B through a 1-1 relation
class A {
  int id;
  B refB;
}

class B {
  int id;
  String attribute;
}

Class descriptor for A will be declared like this:

<class-descriptor class="A" table="TABLE_A">
	<field-descriptor id="1" name="id" column="ID" jdbc-type="INTEGER"
primarykey="true" autoincrement="true" />
	<field-descriptor id="2" name="" column="ID_B" jdbc-type="INTEGER"
/>
	<reference-descriptor name="refB" class-ref="B" auto-update="true">
		<foreignkey field-id-ref="2" />
	</reference-descriptor>
</class-descriptor>

NOTICE that the name of field 2 is "".
-----------------------------------

Amelioration allow to handle referenced object B without having a fk in A.

Case 2: X inherits from Y
class Y {
  int id;
  String AttributeY;
}

class X extends Y {
  String AttributeX;
}

Class descriptor for X will be declared like this:

<class-descriptor class="X" table="TABLE_X">
	<field-descriptor id="1" name="id" column="ID" jdbc-type="INTEGER"
primarykey="true" autoincrement="true" />
	<field-descriptor id="2" name="" column="ID_Y" jdbc-type="INTEGER"
/>
	<reference-descriptor name="" class-ref="B" auto-update="true">
		<foreignkey field-id-ref="2" />
	</reference-descriptor>
</class-descriptor>

NOTICE that the name of field 2 is "" and the name of reference-descriptor
is ""
----------------------------------------------------------------------------
----

Amelioration allow to handle base object Y as a reference-descriptor.


Case3: extent

abstract class U {
  int id;
}

class V extends U {
  ...
}

class W extends U {
  ...
}

The class descriptor is not changed but the amelioration don't need an
attribute ojbConcreteClass to handle objects.


How it works:
I have introduced 
  - AnonymousFieldDescriptor,
  - AnonymousPersistendField,
  - AnonymousPersistendFieldForInheritance,
  - AnonymousObjectReferenceDescriptor,
  - AnonymousFKValue and
  - AnonymousObjConcreteClassValue

and some modifications in the class RepositoryXmlHandler. That's all.

What do you think.

Houar TINE


Mime
View raw message