• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

M. Saeed
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">
<!-- Shouldn't there be an "<id>" element definition here that defines primary key-"RANGE_ID" for the RANGE_VALUES TABLE? -->

// sql DDL

create table RANGE_VALUES (RANGE_ID Number(5), RANGE_INDEX Number(*,0), PERSON_ID VARCHAR2(20) foreign key..., RANGE_VALUE VARCHAR2(10) );
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!