0
JPA 2でこの関係をマップしようとしていて、処理方法がわからない、アプリケーションをHibernate 3から移行する。元のアプリケーションでは、これら2つのオブジェクトがありますJPA 2 Formula Derived Foreign Keyを使用した多対多
CourseCatCode.java
TemplateCourse
TemplateCourse.java
CourseCatCode
に多対一の参照を有します。
TemplateCourse
には外部キーがありません。代わりに、数式を使用して、いくつかの条件に基づいて3番目のテーブルからIDを選択し、対応するCourseCatCodeを結合します。休止3アプリケーションで
は、マッピングは次のようになります。
<many-to-one name="courseCatCode" class="CourseCatCode" not-null="false" insert="false" update="false" lazy="false">
<formula><![CDATA[
(
select
smdp_asbch_course.cat_code_id
from
smdp_asbch_course smdp_asbch_course,
smdp_template_requirement smdp_template_requirement,
smdp_template smdp_template,
smdp_degree smdp_degree
where
smdp_degree.degree_id = smdp_template.degree_id
and smdp_template.template_id = smdp_template_requirement.template_id
and smdp_template_requirement.requirement_id = requirement_id
and smdp_asbch_course.school_id = smdp_degree.school_id
and smdp_degree.degree_type_code = smdp_asbch_course.degree_type_code
and smdp_asbch_course.before_date > SYSDATE
and translate(upper(smdp_asbch_course.course_number), 'A-/ ', 'A') = translate(upper(course_number), 'A-/ ', 'A')
)
]]></formula>
</many-to-one>
は、我々はこの関係をマップするJPA 2で似た何かをすることができますか?私たちのJPA 2プロバイダーもHibernateなので、何か冬眠をする必要があるならそれは大丈夫です。
を試してみました!!!!ありがとう:) –