<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="flybean.db.specification">
<class name="Subject" table="FST_SUBJECT">
<id name="id" column="id" type="string" length="36">
<generator class="uuid.hex" />
</id>
<property name="name" column="name" type="string" length="30" not-null="true"/>
<property name="display" column="display" type="string" length="50" not-null="true"/>
<set name="specifications" lazy="false" inverse="true" cascade="save-update">
<key column="subjectID" />
<one-to-many class="Specification" />
</set>
</class>
<class name="Specification" table="FST_SPEC">
<id name="id" column="id" type="string" length="36">
<generator class="uuid.hex" />
</id>
<property name="name" column="name" type="string" length="30" not-null="true"/>
<property name="display" column="display" type="string" length="50" not-null="true"/>
<property name="type" column="type" type="string" length="10" not-null="true"/>
<property name="length" column="length" type="integer"/>
<property name="scale" column="scale" type="integer"/>
<property name="dispSeq" column="dispSeq" type="integer"/>
<property name="specType" column="specType" type="string" length="10"/>
<many-to-one name="subject" column="subjectID" class="Subject" not-null="true" out-join="false"/>
<joined-subclass name="Column" table="FST_COLUMN">
<key column="id"/>
<property name="database" column="dbName" type="string" length="50"/>
<property name="schema" column="schName" type="string" length="50"/>
<property name="table" column="tblName" type="string" length="50" not-null="true"/>
<property name="topic" column="topicName" type="string" length="50"/>
<property name="data" column="topicDataName" type="string" length="20"/>
<property name="value" column="topicValueName" type="string" length="20"/>
</joined-subclass>
<joined-subclass name="ComputedField" table="FST_FORMULA">
<key column="id"/>
<property name="formula" column="formula" type="string" length="1000" not-null="true"/>
</joined-subclass>
</class>
</hibernate-mapping>
=============================================
DBMS : ORACLE9i
create table FST_SUBJECT (
id CHAR(36) not null,
name VARCHAR(30) not null,
display VARCHAR(50) not null,
constraint PK_FST_SUBJECT primary key (id)
)
/
create table FST_SPEC (
id CHAR(36) not null,
subjectID CHAR(36) not null,
name VARCHAR(30) not null,
display VARCHAR(50) not null,
type VARCHAR(10) not null,
length INTEGER,
scale SMALLINT,
dispSeq SMALLINT,
specType VARCHAR(20) not null,
constraint PK_FST_SPEC primary key (id),
constraint FK_FST_SPEC_REFERENCE_FST_SUBJ foreign key (subjectID)
references FST_SUBJECT (id)
)
create table FST_COLUMN (
id CHAR(36) not null,
dbName VARCHAR(50),
schName VARCHAR(50),
tblName VARCHAR(50) not null,
topicName VARCHAR(50),
topicDataName VARCHAR(20),
topicValueName VARCHAR(20),
constraint PK_FST_COLUMN primary key (id),
constraint FK_FST_COLU_REFERENCE_FST_SPEC foreign key (id)
references FST_SPEC (id)
)
create table FST_FORMULA (
id CHAR(36) not null,
formula VARCHAR(1000) not null,
constraint PK_FST_FORMULA primary key (id),
constraint FK_FST_FORM_REFERENCE_FST_SPEC foreign key (id)
references FST_SPEC (id)
)
Mapping info from Hibernate:
23:15:21,784 INFO Binder:225 - Mapping class: flybean.db.specification.Subject -> FST_SUBJECT
23:15:22,225 DEBUG Binder:449 - Mapped property: id -> id, type: string
23:15:22,445 DEBUG Binder:449 - Mapped property: name -> name, type: string
23:15:22,455 DEBUG Binder:449 - Mapped property: display -> display, type: string
23:15:22,685 DEBUG Binder:449 - Mapped property: specifications, type: java.util.Set
23:15:22,695 INFO Binder:225 - Mapping class: flybean.db.specification.Specification -> FST_SPEC
23:15:22,705 DEBUG Binder:449 - Mapped property: id -> id, type: string
23:15:22,715 DEBUG Binder:449 - Mapped property: name -> name, type: string
23:15:22,725 DEBUG Binder:449 - Mapped property: display -> display, type: string
23:15:22,735 DEBUG Binder:449 - Mapped property: type -> type, type: string
23:15:22,745 DEBUG Binder:449 - Mapped property: length -> length, type: integer
23:15:22,755 DEBUG Binder:449 - Mapped property: scale -> scale, type: integer
23:15:22,936 DEBUG Binder:449 - Mapped property: dispSeq -> dispSeq, type: integer
23:15:22,956 DEBUG Binder:449 - Mapped property: specType -> specType, type: string
23:15:22,976 DEBUG Binder:449 - Mapped property: subject -> subjectID, type: flybean.db.specification.Subject
23:15:23,396 INFO Binder:200 - Mapping joined-subclass: flybean.db.specification.Column -> FST_COLUMN
23:15:23,406 DEBUG Binder:449 - Mapped property: database -> dbName, type: string
23:15:23,416 DEBUG Binder:449 - Mapped property: schema -> schName, type: string
23:15:23,456 DEBUG Binder:449 - Mapped property: table -> tblName, type: string
23:15:23,536 DEBUG Binder:449 - Mapped property: topic -> topicName, type: string
23:15:23,556 DEBUG Binder:449 - Mapped property: data -> topicDataName, type: string
23:15:23,566 DEBUG Binder:449 - Mapped property: value -> topicValueName, type: string
23:15:23,607 INFO Binder:200 - Mapping joined-subclass: flybean.db.specification.ComputedField -> FST_FORMULA
23:15:23,617 DEBUG Binder:449 - Mapped property: formula -> formula, type: string
SQL that hibernate built:
23:15:38,949 DEBUG SQL:223 - select specificat0_.id as id__, subject1_.id as id0_, subject1_.name as name0_, subject1_.display as display0_, specificat0_.id as id1_, case when specificat0__1_.id is not null then 1 when specificat0__2_.id is not null then 2 when specificat0_.id is not null then 0 end as clazz_1_, specificat0_.name as name1_1_, specificat0_.display as display1_1_, specificat0_.type as type1_1_, specificat0_.length as length1_1_, specificat0_.scale as scale1_1_, specificat0_.dispSeq as dispSeq1_1_, specificat0_.specType as specType1_1_, specificat0_.subjectID as subjectID1_1_, specificat0__1_.dbName as dbName2_1_, specificat0__1_.schName as schName2_1_, specificat0__1_.tblName as tblName2_1_, specificat0__1_.topicName as topicName2_1_, specificat0__1_.topicDataName as topicDat6_2_1_, specificat0__1_.topicValueName as topicVal7_2_1_, specificat0__2_.formula as formula3_1_ from FST_SPEC specificat0_ left outer join FST_COLUMN specificat0__1_ on specificat0_.id=specificat0__1_.id left outer join FST_FORMULA specificat0__2_ on specificat0_.id=specificat0__2_.id left outer join FST_SUBJECT subject1_ on specificat0_.subjectID=subject1_.id where specificat0_.id=?
Hibernate: select specificat0_.id as id__, subject1_.id as id0_, subject1_.name as name0_, subject1_.display as display0_, specificat0_.id as id1_, case when specificat0__1_.id is not null then 1 when specificat0__2_.id is not null then 2 when specificat0_.id is not null then 0 end as clazz_1_, specificat0_.name as name1_1_, specificat0_.display as display1_1_, specificat0_.type as type1_1_, specificat0_.length as length1_1_, specificat0_.scale as scale1_1_, specificat0_.dispSeq as dispSeq1_1_, specificat0_.specType as specType1_1_, specificat0_.subjectID as subjectID1_1_, specificat0__1_.dbName as dbName2_1_, specificat0__1_.schName as schName2_1_, specificat0__1_.tblName as tblName2_1_, specificat0__1_.topicName as topicName2_1_, specificat0__1_.topicDataName as topicDat6_2_1_, specificat0__1_.topicValueName as topicVal7_2_1_, specificat0__2_.formula as formula3_1_ from FST_SPEC specificat0_ left outer join FST_COLUMN specificat0__1_ on specificat0_.id=specificat0__1_.id left outer join FST_FORMULA specificat0__2_ on specificat0_.id=specificat0__2_.id left outer join FST_SUBJECT subject1_ on specificat0_.subjectID=subject1_.id where specificat0_.id=?
why "where specifiact0_.id = ?" ?
Should be "subject1_.id = ?",
_________________ Can fly means free.
|