Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String array mapping-id field (i.e primary key) definition

 
M. Saeed
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) If I map an array type field to a separate table ( not the parent table), is there a way to define the primary key field (i.e "id" field) of the child table? The <array> element does not allow an <id> nested element.

2) Is the use of <element> in the mapping below the correct way to map the value of the array type field?

Note that I don't want to use components because i am using table per inheritance hierarchy and only one type in the hierarchy has a range field.

// class definition

public class Person{
String id;
String name;
String[] range;
}


// mapping:

<class ...>
<subclass name="Person" table="PERSON>
<id name="id" column="PERSON_ID/>
<property name="name" column="PERSON_NAME/>

<array name="range" table="RANGE_VALUES" cascade="all">
<key column="person_id" />
<list-index column="range_index" />
<element column="RANGE_VALUE" type="string">
</element>
<!-- Shouldn't there be an "<id>" element definition here that defines primary key-"RANGE_ID" for the RANGE_VALUES TABLE? -->
</array>


// sql DDL

create table RANGE_VALUES (RANGE_ID Number(5), RANGE_INDEX Number(*,0), PERSON_ID VARCHAR2(20) foreign key..., RANGE_VALUE VARCHAR2(10) );
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic