You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Hoell. Uwe" <Ho...@aeb.de> on 2002/12/04 11:12:48 UTC

Mapping complex data types

Is it possible to have an complex type for an field (or any fields) and map
the fields of the complex type as separat columns to the database-table?

Public Class A {
	public String a1;
	public B b1;
	public B b2;
... }

Public class B {
	public String b1;
	public String b2;
... }

Class A should then be mapped to a table like:
tableA(a1, b1b1, b1b2, b2b1, b2b2, ...)


If it's possible, what's about foreign keys for fields in class B, and can I
have nested complex types (means class B has an attribut of type class (or
an interface?) C...)



Thanks,

Uwe Hoell
--
AEB GmbH, www.aeb.de
D-70597 Stuttgart, Julius-Hölder-Str. 39
Tel. +49/711/7 28 42-268, Fax -333, hoell@aeb.de

Re: Mapping complex data types

Posted by Thomas Mahler <th...@apache.org>.
Hi Uwe,

Hoell. Uwe wrote:
> Is it possible to have an complex type for an field (or any fields) and map
> the fields of the complex type as separat columns to the database-table?
> 
> Public Class A {
> 	public String a1;
> 	public B b1;
> 	public B b2;
> ... }
> 
> Public class B {
> 	public String b1;
> 	public String b2;
> ... }
> 
> Class A should then be mapped to a table like:
> tableA(a1, b1b1, b1b2, b2b1, b2b2, ...)
> 

Yes that is possible! It can be done with the NestedPersistentFieldImpl.

> 
> If it's possible, what's about foreign keys for fields in class B, and can I
> have nested complex types (means class B has an attribut of type class (or
> an interface?) C...)
> 

Yes should be possible too. You can use normal FieldDescriptor elements 
and use the foolowing syntax to describe the nested attributes:
<field-descriptor
     name="b1->b1b1"
     ...
/>

Uwe: If I can help you with your evaluation directly just let me know.
You may post your questions in german, which may things simpler for both 
of us ;-)

cheers,
Thomas


> 
> 
> Thanks,
> 
> Uwe Hoell
> --
> AEB GmbH, www.aeb.de
> D-70597 Stuttgart, Julius-Hölder-Str. 39
> Tel. +49/711/7 28 42-268, Fax -333, hoell@aeb.de
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 
>