This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

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) );
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!